Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <map>
- #include <vector>
- #include <cstring>
- #include <algorithm>
- #include <set>
- using namespace std;
- map<string,vector<pair<string,string>>> prof, clase;
- // Multumiri lui GPT pentru tabloul de clase
- set<string> claseList = {
- // Grade 9
- "9A", "9B", "9C", "9D", "9E", "9F", "9G", "9H",
- // Grade 10
- "10A", "10B", "10C", "10D", "10E", "10F", "10G", "10H",
- // Grade 11
- "11A", "11B", "11C", "11D", "11E", "11F", "11G", "11H",
- // Grade 12
- "12A", "12B", "12C", "12D", "12E", "12F", "12G", "12H"
- };
- set<string> profList;
- string getType(string s)
- {
- bool hasLit = false, hasNumber = false;
- for(char c : s)
- {
- if(isdigit(c))
- hasNumber = true;
- else hasLit = true;
- }
- if(hasLit && hasNumber) return "clasa";
- if(hasLit) return "profesor";
- return "nrOre";
- }
- int main()
- {
- cout << "Introdu numele profesorilor. Cand ai terminat scrie 'DONE'\n\n";
- string s = "";
- while(s != "DONE")
- {
- cin >> s;
- if(s != "")
- profList.insert(s);
- }
- cout << "\nIntrodu profesorii, clasele la care sunt si nr de ore pe saptamana\n";
- cout << "Ex : Catalin_Barbu 9G 3 (nu conteaza ordinea)\n\n";
- cout << "Pentru a opri citirea scrie 'DONE'\n\n";
- string info[3];
- bool getOut = false;
- while(true)
- {
- for(int i = 0;i<3;i++)
- {
- cin >> info[i];
- if(info[i] == "DONE")
- {
- getOut = true;
- break;
- }
- }
- if(getOut) break;
- string p = "", cls = "", ore = "";
- for(int i = 0;i<3;i++)
- {
- if(getType(info[i]) == "nrOre")
- ore = info[i];
- if(getType(info[i]) == "profesor")
- p = info[i];
- if(getType(info[i]) == "clasa")
- cls = info[i];
- }
- bool isValid = true;
- if(profList.find(p) == profList.end() || claseList.find(cls) == claseList.end())
- isValid = false;
- if(s == "" || cls == "" || ore == "" || !isValid)
- {
- cout << "Invalid input : ";
- for(int i = 0;i<3;i++)
- cout << info[i] << ' ';
- cout << "\n\n";
- continue;
- }
- prof[p].push_back({cls,ore});
- clase[cls].push_back({p,ore});
- cout << '\n';
- }
- cout << "\nOUTPUT : \n\n";
- cout << "Profesori : \n";
- for(auto it : prof)
- {
- if(it.second.empty())
- continue;
- cout << it.first << '\n';
- for(auto cls : it.second)
- cout << cls.first << ' ' << cls.second << '\n';
- cout << '\n' << '\n';
- }
- cout << "\nClase:\n";
- for(auto it : clase)
- {
- if(it.second.empty()) continue;
- cout << "Clasa " << it.first << '\n';
- for(auto p : it.second)
- cout << p.first << ' ' << p.second << '\n';
- cout << '\n' << '\n';
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment