AcWing 3376. 成绩排序2
原题链接
简单
作者:
故事里的大魔王
,
2025-01-10 12:03:32
,
所有人可见
,
阅读 1
#include <iostream>
#include <algorithm>
using namespace std;
int N = 110;
typedef struct student{
int num;
int score;
}s;
bool cmp(s l, s r){
if(l.score < r.score) return true;
else if(l.score == r.score && l.num < r.num) return true;
else return false;
}
int main(){
int n;
cin >> n;
s arr[N];
for(int i = 0; i < n; ++ i)
cin >> arr[i].num >> arr[i].score;
sort(arr, arr + n, cmp);
for(int i = 0; i < n; ++ i)
cout << arr[i].num << " " << arr[i].score << endl;
return 0;
}