KY9 成绩排序

成绩排序

http://www.nowcoder.com/questionTerminal/3f27a0a5a59643a8abf0140b9a8cf1f7

#include<iostream>
#include<algorithm>
using namespace std;

struct Student{
    int no;
    int score;
};
bool compared(Student std1,Student std2){
    if(std1.score==std2.score)
        return std1.no<std2.no;
    return std1.score<std2.score;
};

int main(){
    Student student[100];
    int N;
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>student[i].no>>student[i].score;
    };
    sort(student,student+N,compared);
    for(int i=0;i<N;i++){
        cout<<student[i].no<<' '<<student[i].score<<endl;
    }
}
全部评论

相关推荐

Yki_:你要算时间成本呀,研究生两三年,博士三四年,加起来就五六年了,如果你本科去腾讯干五年,多领五年的年薪,加上公司内涨薪,可能到时候十五年总薪资也跟博士差不多
点赞 评论 收藏
分享
点赞 评论 收藏
分享
字节一直是我的白月光,考虑到转正还是拒了日常实习。
从今天开始狠狠卷JV...:为什么你释放的offer没流到我头上
点赞 评论 收藏
分享
评论
10
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务