Read n (>) students ' names, school numbers, and grades, respectively, and the names and student numbers of the students with the highest and lowest grades.
Input Format:
Each test input contains 1 test cases in the form
第 1 行:正整数 n第 2 行:第 1 个学生的姓名 学号 成绩第 3 行:第 2 个学生的姓名 学号 成绩 ... ... ...第 n+1 行:第 n 个学生的姓名 学号 成绩
where 姓名
and 学号
both 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, the string has 1 spaces.
Input Sample:
3Joe Math990112 89Mike CS991301 100Mary EE990830 95
Sample output:
Mike CS991301Joe Math990112
Analysis:
C + + Write a structure can
Python can write a simple class
1 //C + +2#include <iostream>3 using namespacestd;4 5typedefstructXXX6 {7 Charname[ the];8 Charnum[ the];9 intscore;Ten }infor; One intMain () A { - intN; -Cin>>N; the if(!N) - return 0; -Infor *inf; -INF =NewInfor[n]; + intMax,min,maxn,minn; -maxn=minn=0; +Max =0; min = -; A for(intI=0; i<n;i++) at { -Cin>>inf[i].name>>inf[i].num>>Inf[i].score; - if(Max <Inf[i].score) - { -Max =Inf[i].score; -MAXN =i; in } - if(Min >Inf[i].score) to { +Min =Inf[i].score; -Minn =i; the } * } $cout<<inf[maxn].name<<' '<<inf[maxn].num<<Endl;Panax Notoginsengcout<<inf[minn].name<<' '<<inf[minn].num<<Endl; - the return 0; +}
pat-Grade B-1004 rankings