SHARE
TWEET

Untitled

a guest Dec 16th, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3. #include <iostream>
  4. #include <vector>
  5. #include <algorithm>
  6. using namespace std;
  7.  
  8. struct student
  9. {
  10.     string surname;
  11.     string patronymic;
  12.  
  13.     int groupnumber;
  14.     vector<int> grades = vector<int>();
  15.  
  16.     bool operator<(student &l)
  17.     {
  18.         int gradres1 = 0;
  19.         for(int i = 0;grades.size();++i)
  20.         {
  21.             gradres1 += grades[i];
  22.         }
  23.  
  24.         int gradres2 = 0;
  25.         for(int i = 0;i<l.grades.size();++i)
  26.         {
  27.             gradres2 += l.grades[i];
  28.         }
  29.  
  30.         return gradres1 < gradres2;
  31.     }
  32. };
  33.  
  34. struct group
  35. {
  36.     vector<student> students = vector<student>();
  37.  
  38.    
  39.     void sortstudents()
  40.     {
  41.         sort(students.begin(), students.end());
  42.     }
  43.  
  44.     void input(student studen)
  45.     {
  46.         students.push_back(studen);
  47.     }
  48.  
  49.     void output()
  50.     {
  51.         for(int i = 0;i<students.size();++i)
  52.         {
  53.             cout << students[i].surname << " " << students[i].patronymic << endl << students[i].groupnumber;
  54.             for (int j = 0; j < students[i].grades.size(); ++j)
  55.                 cout << students[i].grades[j] << " ";
  56.             cout << endl;
  57.         }
  58.     }
  59.  
  60.     void printMark(int mark)
  61.     {
  62.         int flag = 0;
  63.         int count = 0;
  64.         for(int i = 0;i<students.size();++i)
  65.         {
  66.             for(int j = 0;j<students[i].grades.size();++j)
  67.             {
  68.                 if (students[i].grades[j] == mark)
  69.                 {
  70.                     flag = 1;
  71.                     ++count;
  72.                     break;
  73.                 }
  74.             }
  75.  
  76.             if(flag==1)
  77.             {
  78.                 cout << students[i].surname << " " << students[i].patronymic << " " << students[i].groupnumber << endl;
  79.             }
  80.             flag = 0;
  81.         }
  82.  
  83.         if (count == 0)
  84.             cout << "NONE STUDENTS" << endl;
  85.     }
  86. };
  87.  
  88.  
  89. int main()
  90. {
  91.     student studen;
  92.     group gr;
  93.    
  94.     for(int i = 0;i<10;++i)
  95.     {
  96.         cin >> studen.surname >> studen.patronymic >> studen.groupnumber;
  97.         for (int i = 0; i < 5; ++i)
  98.             cin >> studen.grades[i];
  99.         gr.input(studen);
  100.     }
  101.  
  102.     gr.printMark(2);
  103. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top