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的性质 ...
随机推荐
- python 新手题目-文件读写-关键字判断
import os import json import re filename ="D:/pytest/2000/100/111.txt" f = open(filename,& ...
- Java ThreadLocal 源代码分析
Java ThreadLocal 之前在写SSM项目的时候使用过一个叫PageHelper的插件 可以自动完成分页而不用手动写SQL limit 用起来大概是这样的 最开始的时候觉得很困惑,因为直接使 ...
- SQL 查询某时间段的数据 datadiff 计算时间差
datediff语法格式:datediff(day,开始时间,结束时间) 一.应用举例: 上面的代码,将查询 'created_time' > '2016-09-20' 的所有记录. 如果要查 ...
- cocos2d-x安装
mac 安装2.2.6为例 1.进入cocos2d-x/tools/project-creator/ 2.输入 python create_project.py -project HelloWorld ...
- C语言第三周
一. 字符串常量 只要有一对双引号括起来的字符序列就是字符串常量.列如"hello"接"123" 注意:"a"是字符串常量'a'是字符常量. ...
- 20155305 2016-2017-2 《Java程序设计》实验二 Java面向对象程序设计
实验二 Java面向对象程序设计 实验内容 初步掌握单元测试和TDD 理解并掌握面向对象三要素:封装.继承.多态 初步掌握UML建模 熟悉S.O.L.I.D原则 了解设计模式 实验步骤 单元测试 1. ...
- 20145234黄斐《网络对抗技术》PC平台逆向破解
Shellcode注入 基础知识 Shellcode实际是一段代码,但却作为数据发送给受攻击服务器,将代码存储到对方的堆栈中,并将堆栈的返回地址利用缓冲区溢出,覆盖成为指向 shellcode的地址. ...
- java 万能转换器 输入SQL 直接得到ArrayList
//java万能List转换器 public static <T> ArrayList<T> ToList(Class<T> clazz,String sql) t ...
- tkinter事件高级用法实例
from tkinter import * import threading, time trace = 0 class CanvasEventsDemo: def __init__(self, pa ...
- 【转载】D3DXVec3TransformNormal and D3DXVec3TransformCoord
原文:D3DXVec3TransformNormal and D3DXVec3TransformCoord D3DXVec3TransformCoord 对向量进行变换,没啥好说明的,默认向量为行向量 ...