A1083. 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:
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<iostream>
#include<algorithm>
using namespace std;
typedef struct{
char name[];
char id[];
int grade;
}info;
bool cmp(info a, info b){
return a.grade > b.grade;
}
info stu[];
int main(){
int N, high, low, cnt = ;
scanf("%d", &N);
for(int i = ; i < N; i++)
scanf("%s %s %d", stu[i].name, stu[i].id, &(stu[i].grade));
sort(stu, stu + N, cmp);
scanf("%d%d", &low, &high);
for(int i = ; i < N; i++){
if(stu[i].grade >= low && stu[i].grade <= high){
printf("%s %s\n", stu[i].name, stu[i].id);
cnt++;
}
}
if(cnt == )
printf("NONE");
cin >> N;
return ;
}
A1083. List Grades的更多相关文章
- 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甲级——A1083 List Grades
Given a list of N student records with name, ID and grade. You are supposed to sort the records with ...
- PAT_A1083#List Grades
Source: PAT A1083 List Grades (25 分) Description: Given a list of N student records with name, ID an ...
- PAT甲级题解分类byZlc
专题一 字符串处理 A1001 Format(20) #include<cstdio> int main () { ]; int a,b,sum; scanf ("%d %d& ...
- PAT1083:List Grades
1083. List Grades (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Given a l ...
- PAT 甲级 1083 List Grades (25 分)
1083 List Grades (25 分) Given a list of N student records with name, ID and grade. You are supposed ...
- Taking water into exams could boost grades 考试带瓶水可以提高成绩?
Takeing a bottle of water into the exam hall could help students boost their grades, researchers cla ...
- PAT 1083 List Grades[简单]
1083 List Grades (25 分) Given a list of N student records with name, ID and grade. You are supposed ...
随机推荐
- Log4net_简单使用
log4net 有四种主要的组件,分别是Logger(记录器), Repository(库), Appender(附着器)以及 Layout(布局). 第一步:Log4net的安装 Install-P ...
- Docker网络解决方案 - Calico部署记录
简单来说,实现docker跨主机容器间通信,常用的第三方网络方案是Flannel,Weave,Calico:Flannel会为每个host分配一个subnet,容器从这个subnet中分配ip,这些i ...
- 分布式监控系统Zabbix-3.0.3-完整安装记录 - 添加shell脚本监控
对公司的jira访问状态进行监控,当访问状态返回值是200的时候,脚本执行结果为1:其他访问状态返回值,脚本执行结果是0.然后将该脚本放在zabbix进行监控,当非200状态时发出报警.jira访问状 ...
- getUserMedia API及HTML5 调用摄像头和麦克风
getUserMedia API简介 HTML5的getUserMedia API为用户提供访问硬件设备媒体(摄像头.视频.音频.地理位置等)的接口,基于该接口,开发者可以在不依赖任何浏览器插件的条件 ...
- D. Cutting Out
---恢复内容开始--- 链接 [https://codeforces.com/contest/1077/problem/D] 题意 给你n,k,n个数,找出长度为k,的子串(不需连续),使得该子串数 ...
- Map获取key值
有两种方法 public static void test4(){ Map<String, Object> map = new HashMap<>(); map.put(&qu ...
- “北航学堂”M2阶段postmortem
“北航学堂”M2阶段postmortem 设想和目标 1. 我们的软件要解决什么问题?是否定义得很清楚?是否对典型用户和典型场景有清晰的描述? 这个问题我们在M1阶段的时候就已经探讨的比较明确了,就是 ...
- js 基础-&& || 逻辑与和逻辑或
今天百度发现一个简化长if else if 语句的方法,看起来及其强大,感觉这样虽然对系统性能提升没有帮助但是代码更简练了,分析了一番,下面先说说自己学到的理论. 首先要弄清楚js 中对于 变量, ...
- 我的github地址 https://github.com/1010de/Test.git
构建之法老师叫交下任务学习github,经过一段时间的学习和了解,看介绍.看视频.看博客.初步认识到github的方便与好处. 自己试着去注册和使用github,已经慢慢学会了一些基本操作. ...
- Activiti reassign task to another user
//早先胡乱尝试的其他方法,可能对于以后深入学习Activiti有些用处. //taskService.delegateTask(taskId, receiveUserId); //taskServi ...