Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<list>
- #include<iterator>
- using namespace std;
- class adancime
- {
- int nota;
- public:
- adancime(int nota)
- {
- this->nota = nota;
- }
- void afisare_clasa()
- {
- cout << "Nota: " << nota << endl;
- }
- };
- adancime* citire_adancime()
- {
- int nota;
- cout << "Nota: ";
- cin >> nota;
- auto a = new adancime(nota);
- return a;
- }
- class baza
- {
- public:
- list<adancime*>lista_adancime;
- string materie;
- baza(string materie)
- {
- this->materie = materie;
- }
- void afisare()
- {
- cout << "Materie: " << materie << endl;
- }
- void adaugare_adancime()
- {
- lista_adancime.push_back(citire_adancime());
- }
- void afisare_adancime()
- {
- for (auto i : lista_adancime)
- {
- i->afisare_clasa();
- }
- cout << endl;
- }
- };
- baza* citire_baza()
- {
- string nume;
- cout << "Nume: ";
- cin >> nume;
- auto b = new baza(nume);
- return b;
- }
- baza* cautare(list<baza*>listc, string nume)
- {
- for (auto i: listc)
- {
- if (i->materie == nume)
- {
- baza* c;
- c = i;
- return c;
- }
- }
- return NULL;
- }
- void afisare_baza(list<baza*>lista_baza)
- {
- for (auto i : lista_baza)
- {
- cout << "Nume: " << i->materie << endl;
- i->afisare_adancime();
- }
- }
- int main()
- {
- list<baza*>lista_baza;
- int opt;
- string materie;
- do {
- cout << "1. Citire" << endl;
- cout << "2. Afisare" << endl;
- cout << "opt= ";
- cin >> opt;
- switch (opt)
- {
- case 1:
- cout << "1.Baza" << endl;
- cout << "2.Adancime" << endl;
- cout << "opt= ";
- cin >> opt;
- if (opt == 1)
- {
- lista_baza.push_back(citire_baza());
- cout << endl;
- }
- else
- {
- cout << "Materie: ";
- cin >> materie;
- auto c = cautare(lista_baza, materie);
- c->adaugare_adancime();
- }
- break;
- case 2:
- afisare_baza(lista_baza);
- break;
- default:
- break;
- }
- } while (1);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement