#include<iostream>
using namespace std;
typedef struct student {
string name;
string num;
int score;
}STU;
int main(void) {
int n;
cin >> n;
STU max,temp,min;
max.score = 0;
min.score = 100;
for (int i = 0; i < n; i++) {
cin >> temp.name >> temp.num >> temp.score;
if (temp.score > max.score) {
max = temp;
}
if (temp.score < min.score) {
min = temp;
}
}
cout << max.name << ' ' << max.num << '\n';
cout << min.name << ' ' << min.num;
return 0;
}
这一题做起来很顺畅没有遇到什么困难就直接写完了。
有句话是这么说的:看得懂的仔细看,看不懂的反复看。于是我又仔细看了一下别人的代码,发现都基本相同。不知道为什么要到cout后面加上endl。回头看看。