Time limit MS Memory limit 65536 KB code length limit 8000 B procedure StandardAuthor Chen, Yue
Read the names, student numbers and grades of n students, respectively, and output the highest and lowest grade students ' names and school numbers.
input Format: each test input contains 1 test cases in the format
Line 1th: Positive integer n 2nd line: 1th Student's name School number results 3rd line: 2nd Student's name study number score ... Line n+1: Nth Student's name number score
Where both the name and the school number are not more than 10 characters of the string, the score is an integer between 0 and 100, which guarantees that no two students in a set of test cases have the same results.
output format: output 2 lines for each test case, the 1th line is the highest grade student's name and school number, the 2nd line is the lowest grade student's name and school number, there are 1 spaces between the strings.
Input Sample:
3Joe Math990112 89Mike CS991301 100Mary EE990830 95
Sample output:
Mike Cs991301joe Math990112
1 #include <iostream> 2 #include <string> 3 using namespaceStd 4 structstudent{5 String name; 6 string number; 7 int score; 8 }; 9 int Main () {student max1,min,stu[10 1 ];12 int n;cin>> n;13 min.score=101 ; + for (int i=0;i<n;i++ ) {cin>> stu [I].name;16 cin>> stu[i].number;17 cin>> stu[i].score;18 if (stu[i].score> Max1.score) {max1.score= stu[i].score;20 max1.name= stu[i].name;21 max1.number= stu[i].number;22 }23 if (stu[i].score< min.score) {min.score= stu[i].score;25 min.name= stu[i].name;26 min.number= stu[i].number;27 } (} cout<<max1.name<< "" <<max1.number<< " \ n "; cout<<min.name<<" "<<min.number<<" \ n "; return 0 ;
PAT b Water question 1004. Score rankings (20)