社区讨论
WA on #1 , 90pts求条
P5740【深基7.例9】最厉害的学生参与者 3已保存回复 3
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 3 条
- 当前快照
- 1 份
- 快照标识符
- @mjmuov2a
- 此快照首次捕获于
- 2025/12/26 20:31 2 个月前
- 此快照最后确认于
- 2025/12/28 14:50 2 个月前
CPP
#include <iostream>
#include <algorithm>
using namespace std;
int n;
struct node {
string name;
int chinese , maths , english , total;
}a[1010];
bool cmp(node x , node y) {
return x.total > y.total;
}
int main() {
scanf("%d" , &n);
for (int i = 1 ; i <= n ; i++) {
cin >> a[i].name >> a[i].chinese >> a[i].maths >> a[i].english;
a[i].total = a[i].chinese + a[i].maths + a[i].english;
}
sort(a + 1 , a + n + 1 , cmp);
cout << a[1].name << " " << a[1].chinese << " " << a[1].maths << " " << a[1].english;
return 0;
}
回复
共 3 条回复,欢迎继续交流。
正在加载回复...