PAT_1004(中文)_成绩排名
题目地址:http://pat.zju.edu.cn/contests/pat-b-practise/1004
1 #include<iostream> 2 #include<string> 3 #include<vector> 4 5 using namespace std; 6 7 typedef struct{ 8 string name; 9 string stu_id; 10 int grade; 11 }stu; 12 13 int person_num = 0; 14 int i; 15 int main() 16 { 17 stu max, min; 18 max.grade = -1; 19 min.grade = 0x7fffffff; 20 21 cin >> person_num; 22 for( i = 0; i < person_num; ++i ) 23 { 24 stu temp; 25 cin >> temp.name; 26 cin >> temp.stu_id; 27 cin >> temp.grade; 28 if( max.grade < temp.grade ) 29 { 30 max.grade = temp.grade; 31 max.name = temp.name; 32 max.stu_id = temp.stu_id; 33 } 34 if( min.grade > temp.grade ) 35 { 36 min.grade = temp.grade; 37 min.name = temp.name; 38 min.stu_id = temp.stu_id; 39 } 40 } 41 cout << max.name << " " << max.stu_id << endl; 42 cout << min.name << " " << min.stu_id << endl; 43 44 return 0; 45 }