Hezov

Prototip ProfClasa

Sep 24th, 2025
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.04 KB | None | 0 0
  1. #include <iostream>
  2. #include <map>
  3. #include <vector>
  4. #include <cstring>
  5. #include <algorithm>
  6. #include <set>
  7. using namespace std;
  8. map<string,vector<pair<string,string>>> prof, clase;
  9. // Multumiri lui GPT pentru tabloul de clase
  10. set<string> claseList = {
  11.         // Grade 9
  12.         "9A", "9B", "9C", "9D", "9E", "9F", "9G", "9H",
  13.         // Grade 10
  14.         "10A", "10B", "10C", "10D", "10E", "10F", "10G", "10H",
  15.         // Grade 11
  16.         "11A", "11B", "11C", "11D", "11E", "11F", "11G", "11H",
  17.         // Grade 12
  18.         "12A", "12B", "12C", "12D", "12E", "12F", "12G", "12H"
  19.     };
  20. set<string> profList;
  21. string getType(string s)
  22. {
  23.     bool hasLit = false, hasNumber = false;
  24.     for(char c : s)
  25.     {
  26.         if(isdigit(c))
  27.             hasNumber = true;
  28.         else hasLit = true;
  29.     }
  30.     if(hasLit && hasNumber) return "clasa";
  31.     if(hasLit) return "profesor";
  32.     return "nrOre";
  33. }
  34. int main()
  35. {
  36.     cout << "Introdu numele profesorilor. Cand ai terminat scrie 'DONE'\n\n";
  37.  
  38.     string s = "";
  39.     while(s != "DONE")
  40.     {
  41.         cin >> s;
  42.         if(s != "")
  43.             profList.insert(s);
  44.     }
  45.     cout << "\nIntrodu profesorii, clasele la care sunt si nr de ore pe saptamana\n";
  46.     cout << "Ex : Catalin_Barbu 9G 3 (nu conteaza ordinea)\n\n";
  47.     cout << "Pentru a opri citirea scrie 'DONE'\n\n";
  48.     string info[3];
  49.     bool getOut = false;
  50.     while(true)
  51.     {
  52.         for(int i = 0;i<3;i++)
  53.         {
  54.             cin >> info[i];
  55.             if(info[i] == "DONE")
  56.             {
  57.                 getOut = true;
  58.                 break;
  59.             }
  60.         }
  61.         if(getOut) break;
  62.  
  63.         string p = "", cls = "", ore = "";
  64.         for(int i = 0;i<3;i++)
  65.         {
  66.             if(getType(info[i]) == "nrOre")
  67.                 ore = info[i];
  68.             if(getType(info[i]) == "profesor")
  69.                 p = info[i];
  70.             if(getType(info[i]) == "clasa")
  71.                 cls = info[i];
  72.         }
  73.         bool isValid = true;
  74.         if(profList.find(p) == profList.end() || claseList.find(cls) == claseList.end())
  75.             isValid = false;
  76.         if(s == "" || cls == "" || ore == "" || !isValid)
  77.         {
  78.             cout << "Invalid input : ";
  79.             for(int i = 0;i<3;i++)
  80.                 cout << info[i] << ' ';
  81.             cout << "\n\n";
  82.             continue;
  83.         }
  84.         prof[p].push_back({cls,ore});
  85.         clase[cls].push_back({p,ore});
  86.         cout << '\n';
  87.  
  88.     }
  89.     cout << "\nOUTPUT : \n\n";
  90.     cout << "Profesori : \n";
  91.     for(auto it : prof)
  92.     {
  93.         if(it.second.empty())
  94.             continue;
  95.         cout << it.first << '\n';
  96.         for(auto cls : it.second)
  97.             cout << cls.first << ' ' << cls.second << '\n';
  98.         cout << '\n' << '\n';
  99.     }
  100.     cout << "\nClase:\n";
  101.     for(auto it : clase)
  102.     {
  103.         if(it.second.empty()) continue;
  104.         cout << "Clasa " << it.first << '\n';
  105.         for(auto p : it.second)
  106.             cout << p.first << ' ' << p.second << '\n';
  107.         cout << '\n' << '\n';
  108.     }
  109.     return 0;
  110. }
Advertisement
Add Comment
Please, Sign In to add comment