文章
6
粉丝
135
获赞
4
访问
16.6k
#include <bits/stdc++.h>
using namespace std;
struct Student{
int id;
int score;
};
bool cmp(Student x1, Student x2){
if(x1.score == x2.score) return x1.id < x2.id;
else{return x1.score < x2.score;}
}
int main(){
int n;
while(scanf("%d",&n) != EOF){
vector<Student> stu;
for(int i=0; i<n; ++i){
Student a;
scanf("%d %d",&a.id,&a.score);
stu.push_back(a);
}
stable_sort(stu.begin(), stu.end(), cmp);
for(int i=0;i<n;++i){
printf("%d %d\n",stu[i].id,stu[i].score);
}
}
}
登录后发布评论
暂无评论,来抢沙发