Advertisement
Guest User

Untitled

a guest
Apr 17th, 2014
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.23 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.         int num_str = 0;
  9.         bool proverka = true;
  10.         typedef struct student
  11.         {
  12.                 char fio[30];
  13.                 int group;
  14.                 int progr[5];
  15.         };
  16.         cout << "Vvedite massiv studentov: " << endl;
  17.         cin >> num_str;
  18.         cout << "___________________________" << endl;
  19.        
  20.         student* mass = new student[num_str];
  21.         for (int i = 0; i < num_str; i++)
  22.         {
  23.                 cout << i + 1 << ")" << " " << "Vvedite FIO studenta: " << endl;
  24.                 cin >> mass[i].fio; cout << endl;
  25.                 cout << "VVedite nomer grypu: " << " " << endl;
  26.                 cin >> mass[i].group; cout << endl;
  27.                 cout << "Vvedite uspevaemost': " << " " << endl;
  28.                 for (int j = 0; j < 5; j++)
  29.                 {
  30.                         cout << j + 1 << ")" << " ";
  31.                         cin >> mass[i].progr[j];
  32.                 }
  33.                 cout << "___________________________" << endl;
  34.         }
  35.  
  36.    student* temp = new student [num_str];
  37.      
  38.      for (int i = 0; i < num_str; i++)
  39.         {
  40.                 for (int j = i + 1; j < num_str; j++)
  41.                 {
  42.                         if (mass[i].group > mass[j].group)
  43.                         {
  44.                                 temp [i] = mass [i];
  45.                                 mass [i] = mass [j];
  46.                                 mass [j] = temp [i];
  47.                         }
  48.                 }
  49.         }
  50.        
  51.         int sum = 0;
  52.         for (int i = 0; i < num_str; i++)
  53.         {
  54.                 sum = 0;                          // Îáíóëÿåì ê ÷åðòÿì ñîáà÷èì
  55.                 for (int j = 0; j < 5; j++)
  56.                 {
  57.                         sum = sum + mass[i].progr[j];
  58.                 }
  59.                 if (sum / 5 >= 4)
  60.                 {
  61.                         cout << "Uspeshnuy student: " << " " << mass[i].fio << " " << mass[i].group << endl;
  62.                 }
  63.                
  64.         }
  65.  
  66.         if (!(sum / 5 >= 4))
  67.         {
  68.              cout << "Net uspeshnyh studentov!!!" << endl;
  69.         }
  70.        
  71.         _getch();
  72.         return 0;
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement