Guest User

Untitled

a guest
Feb 19th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.10 KB | None | 0 0
  1. #include <conio.h>
  2. #include <iostream>
  3. #include <locale.h>
  4.  
  5.  
  6. using namespace std;
  7.  
  8. const int n=3;       //кол-во записей;
  9.         struct STUDENT
  10. {
  11.         char name[30];
  12.         int  group;
  13.         int  yspev[5];
  14. }       stud1[n],temp[1];
  15.  
  16.         void input()
  17.         {
  18.                 for(int i=0;i<n;i++)
  19.                 {
  20.                         cout << "Введите ФИО: " << endl;
  21.                         cin >> stud1[i].name;
  22.                         cout << "Введите номер группы: " << endl;
  23.                         cin >> stud1[i].group;
  24.                                
  25.                                 cout<<"Введите успеваемость из 5-и оценок: "<<endl;
  26.                                 cin>>stud1[i].yspev[0] >> stud1[i].yspev[1] >> stud1[i].yspev[2]>> stud1[i].yspev[3]>> stud1[i].yspev[4];
  27.                
  28.                 }
  29.                 return;
  30.         }
  31.         void order()
  32.         {    float s[n];
  33.                 for(int i=0;i<n;i++)
  34.                 {
  35.                     s[i]=0;
  36.                     for(int j=0;j<5;j++)
  37.                     {
  38.                         s[i]=stud1[i].yspev[j]+s[i];
  39.                     }
  40.                 };
  41.                 for(int i=0;i<n;i++)
  42.                 {
  43.                     if ((s[i]/5)>(s[i+1]/5))
  44.                     {
  45.                         temp[0]=stud1[i];
  46.                         stud1[i]=stud1[i+1];
  47.                         stud1[i+1]=temp[0];
  48.                     }
  49.                 };
  50.            
  51.                 return;
  52.         }
  53.         void output()
  54.         {
  55.                 int k=0;
  56.                 float s[n],avg;
  57.                 for(int i=0;i<n;i++)
  58.                 {
  59.                         s[i]=0;
  60.                
  61.                 for(int j=0;j<5;j++)
  62.                     {
  63.                         s[i]=stud1[i].yspev[j]+s[i];
  64.                     }
  65.                 };
  66.                
  67.                 cout<<"Студенты у которых средний балл > 4: "<<endl;
  68.                 for(int i=0;i<n;i++)
  69.                 {    avg=s[i]/5;
  70.                         if(avg>=4)
  71.                         {
  72.                                
  73.                                 cout << "ФИО: "<< stud1[i].name << endl;
  74.                                 cout << "№ Группы: "<< stud1[i].group << endl;
  75.                                 cout << "Средний балл: "<< avg << endl << endl;
  76.                                 k++;
  77.                         }}
  78.                         if(k==0) cout<< "Таких студентов нет" << endl;
  79.                        
  80.                
  81.                 return;
  82.         }
  83.             void alloutput()
  84.             {
  85.             for(int i=0;i<n;i++) cout << "ФИО: "<< stud1[i].name << ' ' << "№ Группы: "<< stud1[i].group << endl << endl;
  86.             return;
  87.             }
  88. int main()
  89. {
  90.         setlocale (LC_ALL, "Russian");
  91.         input();
  92.         alloutput();
  93.         order();
  94.         alloutput();
  95.         output();
  96.  
  97.         system("pause");
  98.         return 0;
  99.  
  100.     }
Add Comment
Please, Sign In to add comment