1083. List Grades (25)

时间限制
400 ms

内存限制
65536 kB

代码长度限制
16000 B

判题程序
Standard

作者
CHEN, Yue

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:

N
name[1] ID[1] grade[1]
name[2] ID[2] grade[2]
... ...
name[N] ID[N] grade[N]
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:

4
Tom CS000001 59
Joe Math990112 89
Mike CS991301 100
Mary EE990830 95
60 100

Sample Output 1:

Mike CS991301
Mary EE990830
Joe Math990112

Sample Input 2:

2
Jean AA980920 60
Ann CS01 80
90 95

Sample Output 2:

NONE

解析:本题用的是用空间换时间的策略,所以没有排序等操作。应用的是HASH思想,运用HASH思想一个关键是数组元素的值要和数组元素的下表建立一一影射关系。

/*************************************************************************> File Name: 1083.c> Author: YueBo> Mail: yuebowhu@163.com> Created Time: Sun 14 May 2017 08:26:46 PM CST************************************************************************/#include <stdio.h>
#include <stdlib.h>
#include <string.h>struct student
{char name[16];char id[16];int score;
};int main()
{int N;int i;char name[16];char id[16];int score, down_score, up_score;int flag = 0;scanf("%d", &N);struct student stu_array[101];for (i = 0; i < 101; i++){stu_array[i].score = -1;}for (i = 0; i < N; i++){scanf("%s%s%d", name, id, &score);stu_array[score].score = score;strcpy(stu_array[score].name, name);strcpy(stu_array[score].id, id);}scanf("%d%d", &down_score, &up_score);for (i = 100; i >= 0; i--){if (stu_array[i].score >= down_score && stu_array[i].score <= up_score){printf("%s %s\n", stu_array[i].name, stu_array[i].id);flag = 1;}}if (flag == 0)printf("NONE\n");return 0;
}

1083. List Grades (25)相关推荐

  1. PAT甲级1083 List Grades:[C++题解]结构体、排序

    文章目录 题目分析 题目链接 题目分析 来源:acwing 分析: 结构体存下来所有信息.根据成绩存入vector,然后排序输出即可. ac代码 #include<bits/stdc++.h&g ...

  2. PAT (Advanced Level) Practice 题解代码 - II (1051-1100)

    PAT PAT (Advanced Level) Practice - II(1051-1100) -------------------------------------------------- ...

  3. 刷PAT甲级的各题思路、细节以及遇到的问题记录

    1001 A+B Format (20分) 因为一定会用到字符串,而string非常好用,但是用的时候一定要注意不能越界访问,否则会在运行时出现abort() has been called. 100 ...

  4. PAT题型分类 记录汇总

    这篇博客记录了我在跟着<算法笔记>以及习题册<算法笔记 上机实践指南>刷了PAT的题目之后的一些解题方法的总结与心得. 第三章 入门模拟 1. 简单模拟 一般解题思路 这一小节 ...

  5. 【PAT甲级真题整理三】1061~1090

    目录 1061 Dating(20)字符串处理 1062 Talent and Virtue(25)排序 1063 Set Similarity(25)set的使用 1064 Complete Bin ...

  6. 不使用梯度裁剪和使用梯度裁剪的对比(tensorflow)

    一:不使用梯度裁剪 #网络搭建和模型训练 import tensorflow as tf from tensorflow.keras import layers,optimizers,datasets ...

  7. PAT甲级真题目录(按题型整理)(转自柳神)

    转载自:https://www.liuchuo.net/archives/2502?tdsourcetag=s_pcqq_aiomsg 最短路径 1003. Emergency (25)-PAT甲级真 ...

  8. 【PAT甲级】A1051-A1100刷题记录

    文章目录 (栈) A1051 Pop Sequence (25 分) 0.47 (静态链表) A1052 Linked List Sorting (25 分) 0.21 (静态树+先根遍历DFS) A ...

  9. hdu 2063+hdu 1083(最大匹配数)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2063 二分匹配水题,求最大匹配数(即求边数最多的匹配),匈牙利算法实现.. View Code 1 # ...

最新文章

  1. 领域驱动设计门槛很高,没有深厚的面向对象编码能力很难实践成功
  2. 使用进程池模拟多进程爬取url获取数据,使用进程绑定的回调函数去处理数据...
  3. 《代码整洁之道》(Clean Code)- 读书笔记
  4. vba htm转成图片_提取1000页PPT的图片,同事花了两小时,我只花了两分钟
  5. OpenGLES渲染
  6. SyntaxError: await is only valid in async function
  7. 通过EmbeddedServletContainerCustomizer接口调优Tomcat
  8. EL 11个内置对象
  9. NAND Flash和NOR Flash的比较
  10. c语言实验报告全,c语言实验报告
  11. APP启动无视频数据-YYC松鼠短视频系统
  12. ffplay控制音量方法
  13. 山东专升本计算机知识点(中)
  14. Mybatis中的动态SQL,一对一,一对多以及标签
  15. 怎样在Unity里面进行代码的查错
  16. Access根据出生日期计算年龄_不好意思,Power Query里根据出生日期计算年龄有点儿繁琐!...
  17. 快递100 home.html代码
  18. String.format()的详细用法
  19. DirectX 11 编程指南
  20. easyui部分组件使用经验

热门文章

  1. 前端学习(1289):nodejs模块化的开发规范
  2. Java面试题15牛客 以下关于Integer与int的区别错误的是
  3. 第一百一十一期:思考 | 一文说透秒杀系统如何设计
  4. 第十二期:常用的几种大数据架构剖析
  5. Linux cJSON库的使用、编译为cJSON动态库
  6. VueCli3 项目结构和具体作用
  7. CSS之Background-clip属性
  8. Vh和Vw的简介和使用
  9. 8位可控加减法器_行测高分技巧-资料分析之有效数字加减法取舍
  10. 普通树与二叉树的相互转化及哈夫曼树的了解