Time Limit: 1000 MS memory limit: 65536 kibsubmit statistic discussproblem description the final exam is over, the children's shoes are also out, but in order to rank can be busy teacher, because there are too many students. At this time, the teacher handed you the task and hoped that you could help the teacher complete it. As an IT person, you certainly cannot use stupid human methods. programming is a good solution. There are three courses in total: Chinese, mathematics, and English. The total score is calculated based on the student's scores in each subject and sorted by the total score from high to low. The first line of input is an integer n (n <= 100), which represents the number of students. For the next n rows of data, each row has three integers: C, M, and E, which represent the scores of a student in Chinese, mathematics, and English. Output has n rows in total, each row has one number, from large to small, representing the total score of each student. Sample input370 80 9059 59 59100 100 100 sample output300240177.
1 # include <stdio. h> 2 struct B 3 {4 int shuwen; 5 Int shuxue; 6 int yingyu; 7 int Zong; 8} student [100], T; // define the student struct 9 int main () 10 {11 int A, I, j, N; 12 while (scanf ("% d", & N )! = EOF) 13 {14 for (I = N; I> 0; I --) 15 {16 scanf ("% d", & Student [I]. shuwen, & Student [I]. shuxue, & Student [I]. yingyu); 17 student [I]. zong = student [I]. shuwen + student [I]. shuxue + student [I]. yingyu; 18 19} 20 for (I = 1; I <= n-1; I ++) {// sort 21 for (j = I + 1; j <= N; j ++) 22 if (student [I]. zong <student [J]. zong) 23 {24 t = student [I]; 25 student [I] = student [J]; 26 student [J] = T; 27} 28} // sort by size 29 30 for (I = 1; I <= N; I ++) 31 {32 printf ("% d \ n ", student [I]. zong); 33} 34 return EOF; 35} 36 return 0; 37}
Ranking of the end exam