pat1083. List Grades (25)
1083. List Grades (25)
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
#include<cstdio>
#include<stack>
#include<algorithm>
#include<iostream>
#include<stack>
#include<set>
#include<map>
using namespace std;
map<int,pair<string,string> > ha;//成绩-姓名-id
int main(){
//freopen("D:\\INPUT.txt","r",stdin);
int n;
scanf("%d",&n);
int i,g1,g2;
string name,id;
int grade;
for(i=;i<n;i++){
cin>>name>>id;
scanf("%d",&grade);
ha[grade]=make_pair(name,id);
}
int temp;
scanf("%d %d",&g1,&g2);
if(g1>g2){
temp=g1;
g1=g2;
g2=temp;
}
temp=;
map<int,pair<string,string> >::reverse_iterator it;
for(it=ha.rbegin();it!=ha.rend();it++){
if(it->first>=g1&&it->first<=g2){
cout<<(it->second).first<<" "<<(it->second).second<<endl;
temp++;
}
}
if(!temp){
printf("NONE\n");
}
return ;
}
pat1083. List Grades (25)的更多相关文章
- PAT1083:List Grades
1083. List Grades (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Given a l ...
- 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 ...
- A1083 List Grades (25 分)
Given a list of N student records with name, ID and grade. You are supposed to sort the records with ...
- 【PAT甲级】1083 List Grades (25 分)
题意: 输入一个正整数N(<=101),接着输入N个学生的姓名,id和成绩.接着输入两个正整数X,Y(0<=X,Y<=100),逆序输出成绩在x,y之间的学生的姓名和id. tric ...
- 1083. List Grades (25)
the problem is from PAT,which website is http://pat.zju.edu.cn/contests/pat-a-practise/1083 and the ...
- PAT (Advanced Level) 1083. List Grades (25)
简单排序. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #i ...
- 1083. List Grades (25)-简单的排序
给定区间[L,R],给出在这区间之内的学生,并且按照他们的成绩非升序的顺序输出. #include <iostream> #include <cstdio> #include ...
- PAT_A1083#List Grades
Source: PAT A1083 List Grades (25 分) Description: Given a list of N student records with name, ID an ...
- PAT甲级题解(慢慢刷中)
博主欢迎转载,但请给出本文链接,我尊重你,你尊重我,谢谢~http://www.cnblogs.com/chenxiwenruo/p/6102219.html特别不喜欢那些随便转载别人的原创文章又不给 ...
随机推荐
- 【P2P网贷新手入门】详解借款标的种类及其风险
不同于国外的网贷平台以信用借款标为主,在中国,我们投资网贷平台会看到多样借款标,而投资人往往弄不清自己投资的标属于什么类型的标,特点怎么样,风险如何. 抵 押 标 定义:借款人用自己的房屋车辆等实物在 ...
- ML 徒手系列 最大似然估计
1.最大似然估计数学定义: 假设总体分布为f(x,θ),X1,X2...Xn为总体采样得到的样本.其中X1,X2...Xn独立同分布,可求得样本的联合概率密度函数为: 其中θ是需要求得的未知量,xi是 ...
- C语言学习笔记--struct 和 union关键字
1.struct关键字 C 语言中的 struct 可以看作变量的集合struct中的每个数据成员都有独立的存储空间. 结构体与柔性数组 (1)柔性数组即数组大小待定的数组 (2)C 语言中可以由结构 ...
- SharePoint 2013上传AI格式文件,再次下载后变成了PS格式文件
问题: SharePoint 2013上传AI格式文件,再次下载后变成了PS格式文件 需要下载副本才能显示AI格式 解决办法有两个: 第一种,在客户端机器1. Click Start, click R ...
- Flask17 Flask_Script插件的使用
1 什么是Flask_Script 可以对flask应用做一些统一的操作 flask_script官网:点击前往 2 安装flask_script pip install -i https://pyp ...
- bos物流面试题
BOS物流项目问题汇总 1 请描述一下这个系 统? 从两个方面回答, 第一个方面:系统背景及系统概述 本系统是基于B/S架构而设计开发的,是某物流公司的一个后台管理系统,属于物流公司整个ERP平台的一 ...
- JSP错误页面
exception是JSP九大内置对象之一,其实例代表其他页面的异常和错误.只有当页面是错误处理页面时,即isErroePage为 true时,该对象才可以使用.对于C项,errorPage的实质就是 ...
- kinect2跑高博的orbslam2的过程(仅供自己参考记录)
首先感谢高博的无私奉献!http://www.cnblogs.com/gaoxiang12/p/5161223.html 程序所在的目录为:/home/zty/catkin_ws/src/iai_ki ...
- Docker基本用法
基本操作命令 列举镜像 # docker images 列举容器 # docker ps 运行容器 # docker run -t --name ubuntu -i ubuntu:14.04 /bin ...
- c++第六次实验
part 1 验证性实验 合并两个文件.虽说验证,但后两个实验均受该代码指导启发. part 2 文末添加数据 1.代码 #include<fstream> #include<io ...