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 [grade1grade2] 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

题意:

  给出一个成绩单,按照成绩从大到小输出成绩在[grade1, grade2]之间的学生的信息。

思路:

  构造结构体,排序,输出。

Code:

 1 #include <bits/stdc++.h>
2
3 using namespace std;
4
5 struct Student {
6 string name;
7 string id;
8 int grade;
9 };
10
11 bool cmp(Student a, Student b) { return a.grade > b.grade; }
12
13 int main() {
14 int n;
15 cin >> n;
16 vector<Student> v;
17 for (int i = 0; i < n; ++i) {
18 string name, id;
19 int grade;
20 cin >> name >> id >> grade;
21 v.push_back({name, id, grade});
22 }
23 int grade1, grade2;
24 cin >> grade1 >> grade2;
25 bool found = false;
26 sort(v.begin(), v.end(), cmp);
27 for (int i = 0; i < n; ++i)
28 if (v[i].grade >= grade1 && v[i].grade <= grade2) {
29 found = true;
30 cout << v[i].name << " " << v[i].id << endl;
31 }
32 if (!found) cout << "NONE" << endl;
33
34 return 0;
35 }

1083 List Grades的更多相关文章

  1. PAT 甲级 1083 List Grades (25 分)

    1083 List Grades (25 分) Given a list of N student records with name, ID and grade. You are supposed ...

  2. PAT 1083 List Grades[简单]

    1083 List Grades (25 分) Given a list of N student records with name, ID and grade. You are supposed ...

  3. 1083. List Grades (25)

    the problem is from PAT,which website is http://pat.zju.edu.cn/contests/pat-a-practise/1083 and the ...

  4. PAT 甲级 1083 List Grades

    https://pintia.cn/problem-sets/994805342720868352/problems/994805383929905152 Given a list of N stud ...

  5. PAT 1083 List Grades

    #include <cstdio> #include <cstdlib> using namespace std; class Stu { public: ]; ]; }; i ...

  6. PTA(Advanced Level)1083.List Grades

    Given a list of N student records with name, ID and grade. You are supposed to sort the records with ...

  7. PAT (Advanced Level) 1083. List Grades (25)

    简单排序. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #i ...

  8. 1083. List Grades (25)-简单的排序

    给定区间[L,R],给出在这区间之内的学生,并且按照他们的成绩非升序的顺序输出. #include <iostream> #include <cstdio> #include ...

  9. 【PAT甲级】1083 List Grades (25 分)

    题意: 输入一个正整数N(<=101),接着输入N个学生的姓名,id和成绩.接着输入两个正整数X,Y(0<=X,Y<=100),逆序输出成绩在x,y之间的学生的姓名和id. tric ...

随机推荐

  1. Go的switch

    目录 go的switch 一.语法 二.默认情况 三.多表达式判断 四.无表达式 五.Fallthrough go的switch switch 是一个条件语句,用于多条件匹配,可以替换多个if els ...

  2. 【小菜学网络】MTU

    不同的以太网接入设备,一帧能传输的数据量是有差异的. 普通的以太网卡,一帧最多能够传输 1500 字节的数据:而某些虚拟设备,传输能力要打些折扣.此外,链路层除了以太网还有其他协议,这些协议中数据帧传 ...

  3. There only 10 people use the same phone as you(i春秋CTF题解)

      (1)访问网址进行CTF测试,仅出现登陆与注册的页面 (2)进行注册尝试登陆并进行burp抓取数据包: (3)注册成功,进行登陆尝试查看信息是否具有提示,在登录的页面只有两个点击页面,一个为:Ch ...

  4. golang——net/rpc包学习

    1.rpc包 rpc包提供了通过网络或其他I/O连接对一个对象的导出方法的访问. 只有满足如下标准的方法才能用于远程访问,其余方法会被忽略: (1)方法是导出的(2)方法有两个参数,都是导出类型或内建 ...

  5. WPF 基础 - 属性

    1. CLR 属性 .Net Framework 中的属性又称为 CLR 属性,是对 private 字段的安全访问包装. 使用 ILSpy 反编译器可以看到 C# 中代码的属性的编译结果是 set. ...

  6. Jmeter 分布式架构和服务器性能监控解决方案

    在对项目做大并发性能测试时,常会碰到并发数比较大(比如需要支持10000并发),单台电脑的配置(CPU和内存)可能无法支持,这时可以使用Jmeter提供的分布式测试的功能来搭建分布式并发环境 . 一. ...

  7. [POJ2828] Buy Tickets(待续)

    [POJ2828] Buy Tickets(待续) 题目大意:多组测试,每组给出\(n\)条信息\((a,b)\),表示\(b\)前面有\(a\)个人,顺序靠后的信息优先级高 Solution.1 由 ...

  8. python基础学习之集合set

    .集合:set 特点:无序,不可重复(自动去重),可更改,可以与元组.列表互相转换 格式:s = {'x','y','z'} 转换:(转回用set) s = {'x','y','z'}        ...

  9. P1579_哥德巴赫猜想(JAVA语言)

    题目背景 1742年6月7日哥德巴赫写信给当时的大数学家欧拉,正式提出了以下的猜想:任何一个大于9的奇数都可以表示成3个质数之和.质数是指除了1和本身之外没有其他约数的数,如2和11都是质数,而6不是 ...

  10. cadence Virtuoso ADE原理图AnalogLib库中的switch使用

    Symbol: switch A,B:等效于一个电阻; C,D:等效于控制开关(CD间的控制电压控制AB的断开或闭合); open switch resistance:开关断开状态下的等效电阻(AB之 ...