1083. List Grades (25)

https://www.patest.cn/contests/pat-a-practise/1083
排序

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
struct E{
    char name[15];
    char id[15];
    int  grade;
    bool operator <(const E&b)const{
        return grade>b.grade;
    }
}stu[1005];

int main(){
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%s %s %d",stu[i].name,stu[i].id,&stu[i].grade);
    }
    int grade1,grade2;
    scanf("%d%d",&grade1,&grade2);
    sort(stu,stu+n);
    int tag=0;
    for(int i=0;i<n;i++){
        if(stu[i].grade >= grade1 && stu[i].grade<=grade2){
            tag =1;
            printf("%s %s\n",stu[i].name,stu[i].id);
        }
    }
    if(tag==0) printf("NONE\n");
    return 0;
}
全部评论

相关推荐

2025-12-17 12:08
门头沟学院 产品经理
牛客85811352...:1希音不知道算不算大厂 2完全符合,过得很舒服, 3确实只有杂活 领导找我续签到明年3、4月我要继续吗。主要是边实习边秋招这段时间还是有点累
什么是优秀的实习经历
点赞 评论 收藏
分享
菜菜狗🐶:双非之光
找工作,你会甘心进小厂还...
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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