码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • PAT甲级--1083 List Grades 分数 25


    题目链接:题目详情 - 1083 List Grades (pintia.cn)

    题目:

    Given a list of N student records with name, ID and grade. You are supposed to sort the records with respect to the grade in non-increasing order, and output those student records of which the grades are in a given interval.

    Input Specification:

    Each input file contains one test case. Each case is given in the following format:

    1. N
    2. name[1] ID[1] grade[1]
    3. name[2] ID[2] grade[2]
    4. ... ...
    5. name[N] ID[N] grade[N]
    6. grade1 grade2

    where name[i] and ID[i] are strings of no more than 10 characters with no space, grade[i] is an integer in [0, 100], grade1 and grade2 are the boundaries of the grade's interval. It is guaranteed that all the grades are distinct.

    Output Specification:

    For each test case you should output the student records of which the grades are in the given interval [grade1, grade2] and are in non-increasing order. Each student record occupies a line with the student's name and ID, separated by one space. If there is no student's grade in that interval, output NONE instead.

    Sample Input 1:

    1. 4
    2. Tom CS000001 59
    3. Joe Math990112 89
    4. Mike CS991301 100
    5. Mary EE990830 95
    6. 60 100

    Sample Output 1:

    1. Mike CS991301
    2. Mary EE990830
    3. Joe Math990112

    Sample Input 2:

    1. 2
    2. Jean AA980920 60
    3. Ann CS01 80
    4. 90 95

    Sample Output 2:

    NONE

    代码:

    1. #include
    2. using namespace std;
    3. struct Stu {
    4. string name, ID;
    5. int grade;
    6. };
    7. int cmp(Stu a, Stu b) {
    8. return a.grade > b.grade;
    9. }
    10. int main()
    11. {
    12. int N, st, en, flag = 1;
    13. cin >> N;
    14. vector v(N);
    15. for (int i = 0; i < N; ++i) {
    16. cin >> v[i].name >> v[i].ID >> v[i].grade;
    17. }
    18. cin >> st >> en;
    19. sort(v.begin(), v.end(), cmp);
    20. for (int i = 0; i < N; ++i) {
    21. if (v[i].grade >= st && v[i].grade <= en) {
    22. cout << v[i].name << " " << v[i].ID << endl;
    23. flag = 0;
    24. }
    25. }
    26. if (flag)cout << "NONE";
    27. return 0;
    28. }

  • 相关阅读:
    Web前端:NextJS与React——主要差异、优势和局限性
    Qt的WebEngineView加载网页时出现Error: WebGL is not supported
    给yarn/npm包管理设置代理加速nodejs依赖下载的方法
    在Go中理解栈和先进先出原则
    [react基础]关于v6版本route的变化,以及常见应用模式
    契约锁助力大型能源组织“产-运-储-销-交易”文件电子签
    MPO抗体对丨MPO抗体在治疗疾病领域的应用
    GreenPlum优化点之参数篇
    谷歌学术镜像mark
    LeetCode #104.二叉树的最大深度
  • 原文地址:https://blog.csdn.net/weixin_68051436/article/details/125901492
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号