文章
85
粉丝
0
获赞
391
访问
7.7k
#include <bits/stdc++.h>
using namespace std;
struct student {
int id;
int score;
}s;
bool cmp(student a, student b) {
if (a.score < b.score) return true;
if (a.score ==b.score) {
if (a.id < b.id) return true;
else return false;
}
return false;
}
int main() {
int n;
cin>>n;
vector<student> v;
for (int i=0;i<n;i++) {
int id;
cin>>id;
int score;
cin>>score;
student student;
student.id = id;
student.score = score;
v.push_back(student);
}
sort(v.begin(), v.end(), cmp);
for (int i=0;i<v.size();i++) {
cout<<v[i].id<<" "<<v[i].score<<endl;
}
}
登录后发布评论
暂无评论,来抢沙发