文章
16
粉丝
134
获赞
0
访问
11.5k
#include<bits/stdc++.h>
using namespace std;
struct Student {
string name;
int grade, id;
} stu[1000005];
bool Desc(Student a, Student b) {
return a.grade > b.grade;
}
bool Asc(Student a, Student b) {
return a.grade < b.grade;
}
int main() {
int n,a;
while(cin >> n>>a) {
for(int i = 0; i < n; i++) {
cin >> stu[i].name >> stu[i].grade;
}
if(a == 0)
stable_sort(stu, stu + n, Desc);
else
stable_sort(stu, stu + n, Asc);
for(int i = 0; i < n; i++) {
cout << stu[i].name << " " << stu[i].grade << endl;
&nbs...
登录后发布评论
暂无评论,来抢沙发