0 of 1 Questions completed
Questions:
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading…
You must sign in or sign up to start the quiz.
You must first complete the following:
0 of 1 Questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 point(s), (0)
Earned Point(s): 0 of 0, (0)
0 Essay(s) Pending (Possible Point(s): 0)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
#include <iostream> using namespace std; struct student{ int number; string name; int english; int chinese; int maths; int total; }; int main(){ student students[30]; int max_english=0, max_chinese=0, max_maths=0; float all_english=0, all_chinese=0, all_maths=0; int students_number; cout<<"Please input the number of students:"; cin>>students_number; cout<<"Please input number, name, english, chinese, maths"<<endl; for (int i = 0; i <students_number ; ++i) { cin>>students[i].number; cin>>students[i].name; cin>>students[i].english; cin>>students[i].chinese; cin>>students[i].maths; students[i].total=students[i].english+students[i].chinese+students[i].maths; } for (int i = 0; i < students_number; i++) { all_english=students[i].english+all_english; all_maths=students[i].maths+all_maths; all_chinese=students[i].chinese+all_chinese; if(students[i].english>max_english)max_english=students[i].english; if(students[i].chinese>max_chinese)max_chinese=students[i].chinese; if(students[i].maths>max_maths)max_maths=students[i].maths; } cout<<(all_english/students_number)<<' '; cout<<(all_chinese/students_number)<<' '; cout<<all_maths/students_number<<endl; cout<<max_english<<' '<<max_chinese<<' '<<max_maths<<endl; } |
程序输入:
3
1 li 20 30 40
2 wa 30 40 50
3 zh 40 50 60
请问输出结果为:
备注:输出为两行