Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. struct Diak
  6. {
  7. string Neptun;
  8. int Eredm;
  9. };
  10.  
  11. bool joD(Diak t)
  12. {
  13. bool jo = (t.Eredm >= 1) && (t.Eredm <= 5) && (t.Neptun.length() == 6);
  14. if (!jo)
  15. {
  16. cerr << "Hibas neptunkod vagy eredmeny!" << endl;
  17. }
  18. return jo;
  19. }
  20.  
  21. Diak beolv2(int ind, Diak &t)
  22. {
  23. cerr << "Kerem adja meg a(z) " << ind+1 << ". diak neptunkodjat es eredmenyet!\n";
  24. do
  25. {
  26. cin >> t.Neptun >> t.Eredm;
  27. } while (!joD(t));
  28. return t;
  29. }
  30.  
  31. void beolv(int &N, int &M, vector<Diak> &zh, vector<Diak> &potzh)
  32. {
  33. cerr << "Kerem adja meg a zh-val probalkozo diakok szamat! ";
  34. cin >> N;
  35. cerr << "Kerem adja meg a potzh-val probalkozo diakok szamat! ";
  36. cin >> M;
  37. Diak temp1;
  38. cerr << "ZH:\n";
  39. for (int i = 0; i < N; i++)
  40. {
  41. beolv2(i, temp1);
  42. zh.push_back (temp1);
  43. }
  44. Diak temp2;
  45. cerr << "PotZH:\n";
  46. for (int i = 0; i < M; i++)
  47. {
  48. beolv2(i, temp2);
  49. potzh.push_back (temp2);
  50. }
  51. }
  52.  
  53. void feldolg(int N, int M, int &db, vector<Diak> zh, vector<Diak> potzh, vector<string> &neptunok)
  54. {
  55. db = 0;
  56. for (int i = 0; i < N; i++)
  57. {
  58. for (int j = 0; j < M; j++)
  59. {
  60. if (zh[i].Neptun == potzh[j].Neptun)
  61. {
  62. db++;
  63. neptunok.push_back (zh[i].Neptun);
  64. }
  65. }
  66. }
  67. }
  68.  
  69. void kiiras(int db, vector<string> neptunok)
  70. {
  71. cerr << "Osszesen ";
  72. cout << db;
  73. cerr << " diak probalkozott zhval es potzhval is.\nNeptunkodjaik:" << endl;
  74. for (int i = 0; i < db; i++)
  75. {
  76. cout << neptunok[i] << endl;
  77. }
  78. }
  79.  
  80. int main()
  81. {
  82. int N;
  83. int M;
  84. int db;
  85. vector<Diak> zh;
  86. vector<Diak> potzh;
  87. vector<string> neptunok;
  88. beolv(N,M,zh,potzh);
  89. feldolg(N,M,db,zh,potzh,neptunok);
  90. kiiras(db,neptunok);
  91. return 0;
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement