一遍过

汤姆大人我的神  •  26天前


include <bits/stdc++.h>

using namespace std;

struct stu {

int chinese = 0, maths = 0, english = 0, number, s = 0;

} s[500];

bool cmp(stu a, stu b) {

if (a.s == b.s)
	if (a.chinese == b.chinese)
		return a.number < b.number;
	else
		return a.chinese > b.chinese;
else
	return a.s > b.s;

}

int main() {

int n;
cin >> n;
for (int x = 0; x <= n; x++) {
	s[x].number = x + 1;
	cin >> s[x].chinese >> s[x].maths >> s[x].english;
	s[x].s = s[x].chinese + s[x].maths + s[x].english;
}
sort(s, s + n, cmp);
for (int x = 0; x < 5; x++) {
	cout << s[x].number << ' ' << s[x].s << endl;
}
return 0;

}


评论:

请先登录,才能进行评论