文章
33
粉丝
78
获赞
3
访问
18.4k
#include <stdio.h>
#include <algorithm>
#include <string>
#include <iostream>
using namespace std;
struct student {
string name;
int grade;
}stu[1000];
bool asc(student a, student b) {
return a.grade < b.grade;
}
bool des(student a, student b) {
return a.grade > b.grade;
}
int main() {
int n, order;
while (cin >> n) {
cin >> order;
for (int i = 0;i < n;i++) {
cin >> stu[i].name >> stu[i].grade;
}
if (order == 0) {
stable_sort(stu, stu + n, des);
}
else {
stable_sort(stu,...
登录后发布评论
暂无评论,来抢沙发