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 ...
随机推荐
- React之父子组件传递和其它一些要点
react是R系技术栈中最基础同时也是最核心的一环,2年不到获取了62.5k star(截止到目前),足可见其给力程度.下面对一些react日常开发中的注意事项进行罗列. React的组件生命周期 r ...
- 利用Git工具将本地创建的项目上传到Github上
前言 作为一个对前沿技术很看好的小青年,怎么能不会用Github呢?一年前我创建了Github,也知道git,但是尝试过用,但是就没弄明白,很多粉丝都问我Github的账号,想关注一波,无奈里面啥都没 ...
- Docker阿里云镜像加速
登录阿里云docker registry sudo docker login --username=zhangsan@163.com registry.cn-hangzhou.aliyuncs.com ...
- 浅谈JS的作用域链(三)
前面两篇文章介绍了JavaScript执行上下文中两个重要属性:VO/AO和scope chain.本文就来看看执行上下文中的this. 首先看看下面两个对this的概括: this是执行上下文(Ex ...
- 网络编程学习笔记:Socket编程
文的主要内容如下: 1.网络中进程之间如何通信? 2.Socket是什么? 3.socket的基本操作 3.1.socket()函数 3.2.bind()函数 3.3.listen().connect ...
- 【个人总结】软件工程M1/M2总结
个人博客连接: http://www.cnblogs.com/lwq12061168/p/4094252.html http://www.cnblogs.com/lwq12061168/p/40284 ...
- JAVA面对对象(五)——接口
接口由全局常量和公共的抽象方法组成,接口的定义格式: interface 接口名称{ 全局常量; 抽象方法; } 接口中的抽象方法必须定义为public访问权限,在接口中如果不写也默认是public访 ...
- SVN上传下载项目
1 本机安装svn服务器 1.1 创建新库 创建分支, Trunk:主干, Tags:分支节点 Branches:分支 比如说我们现在tomcat出了6.0以后已经定版了,但是还得继续开发呀,开 ...
- PAT L2-002 链表去重
https://pintia.cn/problem-sets/994805046380707840/problems/994805072641245184 给定一个带整数键值的链表 L,你需要把其中绝 ...
- PAT 1082 射击比赛
https://pintia.cn/problem-sets/994805260223102976/problems/994805260990660608 本题目给出的射击比赛的规则非常简单,谁打的弹 ...