Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <conio.h>
- #include <iostream>
- #include <locale.h>
- using namespace std;
- const int n=3; //кол-во записей;
- struct STUDENT
- {
- char name[30];
- int group;
- int yspev[5];
- } stud1[n],temp[1];
- void input()
- {
- for(int i=0;i<n;i++)
- {
- cout << "Введите ФИО: " << endl;
- cin >> stud1[i].name;
- cout << "Введите номер группы: " << endl;
- cin >> stud1[i].group;
- cout<<"Введите успеваемость из 5-и оценок: "<<endl;
- cin>>stud1[i].yspev[0] >> stud1[i].yspev[1] >> stud1[i].yspev[2]>> stud1[i].yspev[3]>> stud1[i].yspev[4];
- }
- return;
- }
- void order()
- { float s[n];
- for(int i=0;i<n;i++)
- {
- s[i]=0;
- for(int j=0;j<5;j++)
- {
- s[i]=stud1[i].yspev[j]+s[i];
- }
- };
- for(int i=0;i<n;i++)
- {
- if ((s[i]/5)>(s[i+1]/5))
- {
- temp[0]=stud1[i];
- stud1[i]=stud1[i+1];
- stud1[i+1]=temp[0];
- }
- };
- return;
- }
- void output()
- {
- int k=0;
- float s[n],avg;
- for(int i=0;i<n;i++)
- {
- s[i]=0;
- for(int j=0;j<5;j++)
- {
- s[i]=stud1[i].yspev[j]+s[i];
- }
- };
- cout<<"Студенты у которых средний балл > 4: "<<endl;
- for(int i=0;i<n;i++)
- { avg=s[i]/5;
- if(avg>=4)
- {
- cout << "ФИО: "<< stud1[i].name << endl;
- cout << "№ Группы: "<< stud1[i].group << endl;
- cout << "Средний балл: "<< avg << endl << endl;
- k++;
- }}
- if(k==0) cout<< "Таких студентов нет" << endl;
- return;
- }
- void alloutput()
- {
- for(int i=0;i<n;i++) cout << "ФИО: "<< stud1[i].name << ' ' << "№ Группы: "<< stud1[i].group << endl << endl;
- return;
- }
- int main()
- {
- setlocale (LC_ALL, "Russian");
- input();
- alloutput();
- order();
- alloutput();
- output();
- system("pause");
- return 0;
- }
Add Comment
Please, Sign In to add comment