文章

33

粉丝

42

获赞

3

访问

9.8k

头像
成绩排序 题解:
P1151 清华大学上机题
发布于2024年3月13日 17:04
阅读数 353

#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,...

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发