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

思路
要求按成绩降序输出给定成绩区间学生的信息。考虑到成绩不超过100而且唯一,可以用桶排序的思想来直接排序输出而不用比较。
1.用两种桶name[101]和ID[101]分别存放姓名和ID。
2.用成绩代表桶的下标,把对应成绩的学生信息放入桶中。如Jack CS00001 60 ---等价于---> name[60] = "Jack", ID[60] = "CS00001"。
3.根据区间范围输出不为空的桶里面的信息即可。如果范围内的桶都为空输出"NONE"。
代码
#include<iostream>
#include<vector>
#include<string>
using namespace std;
vector<string> name();
vector<string> ID(); int main()
{
int N;
while(cin >> N)
{
string n,id;
for(int i = ;i < N;i++)
{
int grade;
cin >> n >> id >> grade;
name[grade] = n;
ID[grade] = id;
}
int j,k;
bool isNone = true;
cin >> j >> k;
for(;k >= j;k--)
{
if(name[k] != "")
{
isNone = false;
cout << name[k] << " " << ID[k] << endl;
}
}
if(isNone)
cout <<"NONE" << endl;
ID.clear();
name.clear();
}
}
 

PAT1083:List Grades的更多相关文章

  1. pat1083. List Grades (25)

    1083. List Grades (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Given a l ...

  2. PAT 甲级 1083 List Grades (25 分)

    1083 List Grades (25 分) Given a list of N student records with name, ID and grade. You are supposed ...

  3. A1083. List Grades

    Given a list of N student records with name, ID and grade. You are supposed to sort the records with ...

  4. Taking water into exams could boost grades 考试带瓶水可以提高成绩?

    Takeing a bottle of water into the exam hall could help students boost their grades, researchers cla ...

  5. PAT 1083 List Grades[简单]

    1083 List Grades (25 分) Given a list of N student records with name, ID and grade. You are supposed ...

  6. PAT 甲级 1083 List Grades

    https://pintia.cn/problem-sets/994805342720868352/problems/994805383929905152 Given a list of N stud ...

  7. PAT 1083 List Grades

    #include <cstdio> #include <cstdlib> using namespace std; class Stu { public: ]; ]; }; i ...

  8. A1083 List Grades (25)(25 分)

    A1083 List Grades (25)(25 分) Given a list of N student records with name, ID and grade. You are supp ...

  9. A1083 List Grades (25 分)

    Given a list of N student records with name, ID and grade. You are supposed to sort the records with ...

随机推荐

  1. 【一天一道LeetCode】#38. Count and Say

    一天一道LeetCode系列 (一)题目 The count-and-say sequence is the sequence of integers beginning as follows: 1, ...

  2. (视频)《快速创建网站》2.1 在Azure上创建网站及网站运行机制

    现在让我们开始一天的建站之旅. 本文是<快速创建网站>系列的第2篇,如果你还没有看过之前的内容,建议你点击以下目录中的章节先阅读其他内容再回到本文. 1. 网站管理平台WordPress和 ...

  3. Matlab以MEX方式调用C源代码

    #include "mex.h" // 使用MEX文件必须包含的头文件 // 执行具体工作的C函数 double add(double x, double y) { return ...

  4. ERP-非财务人员的财务培训教(四)------公司/部门的成本与费用控制

    一.损益表.资产负责表 二.成本分类 ----成本习性 三.成本核算模式 四.成本控制原则 第四部分 公司/部门的成本与费用控制   一.损益表.资产负责表   项目 Items 产品销售收入 Sal ...

  5. MySql常用操作语句(1:启动、连接数据库及用户操作)

    下方将个人常用的MySql操作语句(Win7下)总结如下: 1. 启动与关闭数据库 “管理员”权限, MySql安装目录下bin目录//:  1.1 启动 @>net start mysql   ...

  6. Linux - Shell变量的配置守则

    变量的配置守则 变量与变量内容以一个等号『=』来连结,如下所示: 『myname=VBird』 等号两边不能直接接空格符,如下所示为错误: 『myname = VBird』或『myname=VBird ...

  7. TCP连接建立系列 — 服务端接收ACK段(二)

    本文主要分析:三次握手中最后一个ACK段到达时,服务器端的处理路径. 内核版本:3.6 Author:zhangskd @ csdn blog 创建新sock 协议族相关的操作函数,我们要看的是TCP ...

  8. SharePoint 调用WebService操作List小记

    简述:在SharePoint的使用中,经常需要进行系统集成这样的操作,我们作为SharePoint开发,就需要给其他系统提供接口,而SharePoint提供的WebService就很好的提供了这样的功 ...

  9. JAVA加密技术-----MD5 与SHA 加密

    关于JAVA的加密技术有很多很多,这里只介绍加密技术的两种 MD5与 SHA. MD5与SHA是单向加密算法,也就是说加密后不能解密. MD5 ---信息摘要算法,广泛用于加密与解密技术,常用于文件校 ...

  10. ruby用来发送互联网邮件

    其实只要你任性的可以,用telnet也是可以发邮件的哦.不过本猫没那么任性,还是用KISS原则来发邮件吧.本篇博文只介绍了如何发邮件,但没涉及收邮件的事,以后如有机会会单独开一篇博文介绍. ruby通 ...