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;
    }
}
全部评论

相关推荐

点赞 评论 收藏
分享
每晚夜里独自颤抖:你cet6就cet6,cet4就cet4,你写个cet证书等是什么意思。专业技能快赶上项目行数,你做的这2个项目哪里能提现你有这么多技能呢
点赞 评论 收藏
分享
人力小鱼姐:实习经历没有什么含金量,咖啡店员迎宾这种就别写了,其他两段包装一下 想找人力相关的话,总结一下个人优势,结合校园经历里有相关性的部分,加一段自我评价
点赞 评论 收藏
分享
评论
10
收藏
分享

创作者周榜

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