PAT甲级——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 <iostream>
#include <string>
#include <algorithm>
using namespace std;
struct Node
{
string name, id;
int grade;
};
int main()
{
int N, grade1, grade2;
cin >> N;
Node* data = new Node[N];
for (int i = ; i < N; ++i)
cin >> data[i].name >> data[i].id >> data[i].grade;
cin >> grade1 >> grade2;
sort(data, data + N, [](Node a, Node b) {return a.grade > b.grade; });
int flag = ;
for (int i = ; i < N; ++i)
{
if (data[i].grade < grade1)
break;
if (data[i].grade >= grade1 && data[i].grade <= grade2)
{
cout << data[i].name << " " << data[i].id << endl;
flag = ;
}
}
if (flag == )
cout << "NONE" << endl;
delete[]data;
return ;
}
PAT甲级——A1083 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 甲级 1083 List Grades
https://pintia.cn/problem-sets/994805342720868352/problems/994805383929905152 Given a list of N stud ...
- 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甲级题解分类byZlc
专题一 字符串处理 A1001 Format(20) #include<cstdio> int main () { ]; int a,b,sum; scanf ("%d %d& ...
- 1080 Graduate Admission——PAT甲级真题
1080 Graduate Admission--PAT甲级练习题 It is said that in 2013, there were about 100 graduate schools rea ...
- PAT甲级:1036 Boys vs Girls (25分)
PAT甲级:1036 Boys vs Girls (25分) 题干 This time you are asked to tell the difference between the lowest ...
随机推荐
- PHP出现报警后需要修改 date.timezone 的值(php.ini)
PHP调试的时候出现了警告: It is not safe to rely on the system解决方法,其实就是时区设置不正确造成的,本文提供了3种方法来解决这个问题. 实际上,从PHP 5. ...
- ci用户登录
[list] 预先加载数据库操作类和Session类 即在autoload.php中,$autoload['libraries'] = array('database', 'session'); a. ...
- leetcode-5-最长回文子串*马拉车
方法一:动态规划 O(n2) O(n2) class Solution: def longestPalindrome(self, s: str) -> str: size = len(s) if ...
- leetcode-50-pow()
题目描述: 方法一: class Solution: def myPow(self, x: float, n: int) -> float: if n<0: x = 1/x return ...
- p分位数的原理及计算
p分位数的原理及计算 大纲>> 1.统计上的分位数概念 2.分位数的计算方法及举例 2.1首先确定p分位数的位置(依据项数分为基数.偶数情况) 2.2 求上一步确定的p分位数位置处的具 ...
- duilib教程之duilib入门简明教程13.复杂控件介绍
首先将本节要介绍的控件全部拖到界面上,并调整好位置,如图: 然后将Name属性改成其他名字, 不能是[控件名+UI+数字]这种,因为这是DuiDesigner默认的名字,它不会实际写 ...
- (转)Java ClassLoader详解
转:http://java.chinaitlab.com/base/804400.html 类加载器是 Java 语言的一个创新,也是 Java 语言流行的重要原因之一.它使得 Java 类可以被动态 ...
- php算法题---连续子数组的最大和
php算法题---连续子数组的最大和 一.总结 一句话总结: 重要:一定要本机调试过了再提交代码,因为很容易出现考虑不周的情况,或者修改了之后没有考虑修改的这部分 利用空间来换时间,或者利用空间来换算 ...
- PHP如何实现百万级数据导出
公司目前有一个需求,需要对一个日增量在20万+数据量的数据表中的数据进行可自定义条件筛选的导出数据,该功能需要对多个部门进行开发使用,要保证功能可用的前提下,尽量优化体验. 首先介绍一下当前可利用的资 ...
- VS2010-MFC(图形图像:CDC类及其屏幕绘图函数)
转自:http://www.jizhuomi.com/software/244.html 上一节讲了文本输出的知识,本节的主要内容是CDC类及其屏幕绘图函数. CDC类简介 CDC类是一个设备上下文类 ...