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


    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. #include
    3. #include
    4. using namespace std;
    5. struct Stu {
    6. string name, id;
    7. int score;
    8. } a[100010];
    9. int n, g1, g2, cnt;
    10. bool cmp(Stu s1, Stu s2) {
    11. return s1.score > s2.score;
    12. }
    13. int main() {
    14. cin >> n;
    15. for (int i = 0; i < n; i++) {
    16. cin >> a[i].name >> a[i].id >> a[i].score;
    17. }
    18. cin >> g1 >> g2;
    19. sort(a, a + n, cmp);
    20. for (int i = 0; i < n; i++) {
    21. if (a[i].score >= g1 && a[i].score <= g2) {
    22. cout << a[i].name << ' ' << a[i].id << endl;
    23. cnt++;
    24. }
    25. if (a[i].score < g1) {
    26. break;
    27. }
    28. }
    29. if (!cnt) {
    30. cout << "NONE";
    31. }
    32. return 0;
    33. }

     

  • 相关阅读:
    SpringBoot-Web开发-文件上传
    spring的bean初始化策略
    LabVIEW本地化VI
    Spring Cloud Alibaba-Sentinel规则
    Nginx网络服务之监控模块
    港科夜闻|香港特首李家超,教育局局长蔡若莲与创新科技及工业局局长孙东亲临香港科大,聆听青年才俊之声...
    【科学文献计量】科学文献知识网络分析基础
    软考架构设计师知识点
    【基础讲解】基于matpower的电力系统潮流计算(Matlab代码实现)
    Intel 开发手册
  • 原文地址:https://blog.csdn.net/weixin_53199925/article/details/126701373
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | 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号