文章
34
粉丝
0
获赞
6
访问
1.0k
#include<bits/stdc++.h>
using namespace std;
struct Student{
int id;
int grade;
}stu[105];
bool cmp(Student a, Student b){
if(a.grade == b.grade) return a.id < b.id;
else return a.grade < b.grade;
}
int main(){
int n; cin >> n;
int cnt = n;
while(n --){
cin >> stu[n].id >> stu[n].grade;
}
sort(stu, stu+cnt, cmp);
for(int i = 0; i < cnt; i++){
cout << stu[i].id << " " << stu[i].grade << endl;
}
return 0;
}
登录后发布评论
暂无评论,来抢沙发