1004 成绩排名 (20 分)

#include <iostream>
using namespace std;
struct Stu
{
    int score;
    string id, num;
}stu;
int main(){
    string s1 ,s2 , s3, s4;
    int n, max = 0, min = 110;
    cin >> n;
    while (n--) {
        cin >> stu.id >> stu.num >> stu.score;
        if (stu.score > max){
            max = stu.score;
            s1 = stu.id;
            s2 = stu.num;
        }
        if (stu.score < min){
            min = stu.score;
            s3 = stu.id;
            s4 = stu.num;
        }
    }
    cout << s1 << ' ' << s2 << endl << s3 << ' ' << s4 << endl;
    return 0;
}
原文地址:https://www.cnblogs.com/Hk456/p/10714272.html