1004 Score ranking (20 branch )

Read in  n(>0) Names of students , Student number , achievement , Output the names and student numbers of the students with the highest and lowest scores respectively .

Input format :

Each test input contains 1 Test cases , Format is
The first 1 that 's ok : positive integer n The first 2 that 's ok : The first 1 Names of students Student number achievement The first 3 that 's ok : The first 2 Names of students Student number achievement .. .. ... The first n+1
that 's ok : The first n Names of students Student number achievement
The name and student number are no more than 10 Character string , The result is 0 reach 100 An integer between , It is guaranteed that no two students have the same score in a set of test cases .

Output format :

Output for each test case 2 that 's ok , The first 1 Line is the name and student number of the student with the highest score , The first 2 Line is the name and student number of the student with the lowest score , Between strings 1 Space .

sample input :
3 Joe Math990112 89 Mike CS991301 100 Mary EE990830 95
sample output :
Mike CS991301 Joe Math990112
code :
#include <iostream> #include <map> using namespace std; typedef struct{
string name,sno; int score; } student; int main(){ int n,max = 0,min = 0;
student s[1000]; cin>>n; for(int i = 0;i<n;i++){ cin>>s[i].name; cin>>s[i].sno;
cin>>s[i].score; } for(int i = 0;i<n;i++){ if(s[i].score>s[max].score) max = i;
if(s[i].score<s[min].score) min = i; } cout<<s[max].name<<"
"<<s[max].sno<<endl; cout<<s[min].name<<" "<<s[min].sno; }

Technology