PAT 甲级 1083 List Grades
https://pintia.cn/problem-sets/994805342720868352/problems/994805383929905152
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 <bits/stdc++.h>
using namespace std; const int maxn = 1e5 + 10;
int N;
int L, R; struct Node{
char name[15];
char id[15];
int score;
}node[maxn]; bool cmp(const Node& a, const Node& b) {
return a.score > b.score;
} int main() {
scanf("%d", &N);
for(int i = 0; i < N; i ++)
scanf("%s%s%d", node[i].name, node[i].id, &node[i].score);
scanf("%d%d", &L, &R);
sort(node, node + N, cmp);
int cnt = 0;
for(int i = 0; i < N; i ++) {
if(node[i].score >= L && node[i].score <= R) {
cnt ++;
printf("%s %s\n", node[i].name, node[i].id);
}
}
if(!cnt) printf("NONE\n");
return 0;
}
真滴是很久不见啦!
PAT 甲级 1083 List Grades的更多相关文章
- PAT 甲级 1083 List Grades (25 分)
1083 List Grades (25 分) Given a list of N student records with name, ID and grade. You are supposed ...
- 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 1083 List Grades[简单]
1083 List Grades (25 分) Given a list of N student records with name, ID and grade. You are supposed ...
- PAT甲级题解(慢慢刷中)
博主欢迎转载,但请给出本文链接,我尊重你,你尊重我,谢谢~http://www.cnblogs.com/chenxiwenruo/p/6102219.html特别不喜欢那些随便转载别人的原创文章又不给 ...
- 【转载】【PAT】PAT甲级题型分类整理
最短路径 Emergency (25)-PAT甲级真题(Dijkstra算法) Public Bike Management (30)-PAT甲级真题(Dijkstra + DFS) Travel P ...
- PAT甲级题分类汇编——排序
本文为PAT甲级分类汇编系列文章. 排序题,就是以排序算法为主的题.纯排序,用 std::sort 就能解决的那种,20分都算不上,只能放在乙级,甲级的排序题要么是排序的规则复杂,要么是排完序还要做点 ...
- PAT甲级题分类汇编——序言
今天开个坑,分类整理PAT甲级题目(https://pintia.cn/problem-sets/994805342720868352/problems/type/7)中1051~1100部分.语言是 ...
- PAT 甲级真题题解(63-120)
2019/4/3 1063 Set Similarity n个序列分别先放进集合里去重.在询问的时候,遍历A集合中每个数,判断下该数在B集合中是否存在,统计存在个数(分子),分母就是两个集合大小减去分 ...
- PAT甲级目录
树(23) 备注 1004 Counting Leaves 1020 Tree Traversals 1043 Is It a Binary Search Tree 判断BST,BST的性质 ...
随机推荐
- laravel5实现微信第三方登录功能
背景 最近手头一个项目需要实现用户在网站的第三方登录(微信和微博),后端框架laravel5.4. 实现过程以微信网页版第三方登录,其他于此类似,在此不做重复. 准备工作 网站应用微信登录是基于OAu ...
- hello,Python
Python无疑是近年来程序语言届最闪亮的明星.2018年Python被TIOBE授予年度编程语言称号,在一月的排行榜中也雄踞第三位,打破了Java C C++长期以来所保持的三强局面 对比笔者以前学 ...
- c语言宏
使用 c语言的宏是在预处理时候对字符进行简单替换. 优点:1.如果要改一个变量,只需要改宏就可以了,也就是只改一次;2.宏函数展开和普通函数一样,但是它没有普通函数调用的过程,不需要压栈出栈等操作,所 ...
- 中国大学MOOC-JAVA学习(浙大翁恺)—— 时间换算
import java.util.Scanner; public class Main { public static void main(String[] args) { // TODO Auto- ...
- 将python自动转换为.exe文件
使用py2exe包进行转换.py2exe怎么装的可以网上另查.时间久了,记不太清了...... 这个程序可以把自己进行转换.但是没法运行....其实只要是需要修改自身的程序打包后都没法运行. # -* ...
- Lingo安装
Lingo安装 Lingo简介 LINGO是Linear Interactive and General Optimizer的缩写,即"交互式的线性和通用优化求解器" ...
- 【Windows10】我的电脑从新装到优化配置
[Windows10]我的电脑从新装到优化配置 必装软件 Visual Studio Microsoft VS Code Microsoft Expression Design 4 Notepad2- ...
- 使用三层交换机实现不同vlan的互通
如下拓扑图所示,要实现vlan10(192.168.10.0/24)与vlan 20(192.168.20.0/24)的网络互通. 三层交换机配置: 创建vlan:Switch#configure t ...
- Mysql:查询当天、今天、本周、上周、本月、上月、本季度、本年的数据
1. 今天 select * from 表名 WHERE TO_DAYS(时间字段名) = TO_DAYS(NOW()); 2. 昨天 3. 本周 SELECT * FROM 表名 WHERE YEA ...
- 第七篇 Postman+Node.js+Newman+Jenkins实现自动化测试
今天终于不咋忙了,学习整理一下一直想做却没实现的事儿,这事已经折磨团队半年之久了.因为项目是B端业务的测试,测试过程中需要生产大量的测试数据,而且都是跨多个系统的测试,对于后置流程的测试,这些同学往往 ...