Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- struct Diak
- {
- string Neptun;
- int Eredm;
- };
- bool joD(Diak t)
- {
- bool jo = (t.Eredm >= 1) && (t.Eredm <= 5) && (t.Neptun.length() == 6);
- if (!jo)
- {
- cerr << "Hibas neptunkod vagy eredmeny!" << endl;
- }
- return jo;
- }
- Diak beolv2(int ind, Diak &t)
- {
- cerr << "Kerem adja meg a(z) " << ind+1 << ". diak neptunkodjat es eredmenyet!\n";
- do
- {
- cin >> t.Neptun >> t.Eredm;
- } while (!joD(t));
- return t;
- }
- void beolv(int &N, int &M, vector<Diak> &zh, vector<Diak> &potzh)
- {
- cerr << "Kerem adja meg a zh-val probalkozo diakok szamat! ";
- cin >> N;
- cerr << "Kerem adja meg a potzh-val probalkozo diakok szamat! ";
- cin >> M;
- Diak temp1;
- cerr << "ZH:\n";
- for (int i = 0; i < N; i++)
- {
- beolv2(i, temp1);
- zh.push_back (temp1);
- }
- Diak temp2;
- cerr << "PotZH:\n";
- for (int i = 0; i < M; i++)
- {
- beolv2(i, temp2);
- potzh.push_back (temp2);
- }
- }
- void feldolg(int N, int M, int &db, vector<Diak> zh, vector<Diak> potzh, vector<string> &neptunok)
- {
- db = 0;
- for (int i = 0; i < N; i++)
- {
- for (int j = 0; j < M; j++)
- {
- if (zh[i].Neptun == potzh[j].Neptun)
- {
- db++;
- neptunok.push_back (zh[i].Neptun);
- }
- }
- }
- }
- void kiiras(int db, vector<string> neptunok)
- {
- cerr << "Osszesen ";
- cout << db;
- cerr << " diak probalkozott zhval es potzhval is.\nNeptunkodjaik:" << endl;
- for (int i = 0; i < db; i++)
- {
- cout << neptunok[i] << endl;
- }
- }
- int main()
- {
- int N;
- int M;
- int db;
- vector<Diak> zh;
- vector<Diak> potzh;
- vector<string> neptunok;
- beolv(N,M,zh,potzh);
- feldolg(N,M,db,zh,potzh,neptunok);
- kiiras(db,neptunok);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement