#include<stdio.h>
#include<algorithm>
using namespace std;
struct Student {
int num;
int score;
} student[110];
bool cmp(Student a, Student b) {
if (a.score != b.score) {
return a.score < b.score;
} else {
return a.num < b.num;
}
}
int main() {
int n;
while (scanf("%d", &n) != EOF) {
for (int i = 0; i < n; i++) {
scanf("%d%d", &student[i].num, &student[i].score);
}
sort(student, student + n, cmp);
for (int i = 0; i < n; i++) {
printf("%d %d\n", student[i].num, student[i].score);//别忘回车
}
}
return 0;
}
/**************************************************************
Problem: 1196
User: cust123
Language: C++
Result: Accepted
Time:30 ms
Memory:1020 kb
****************************************************************/
题目1196:成绩排序
最新推荐文章于 2023-01-29 22:40:24 发布