1083 List Grades (25 分)

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
 #include<iostream>
#include<set>
#include<string> using namespace std; struct student
{
string name;
string ID;
int grade; bool operator<(const student stu) const
{
if(grade < stu.grade)
return true;
else
return false;
} bool operator>(const student stu) const
{
if(grade > stu.grade)
return true;
else
return false;
}
}; int main()
{
int N ,flag = ,grade1,grade2;
student stu;
set<student> s; cin>>N; for(int i=;i<N;++i)
{
cin>>stu.name>> stu.ID>>stu.grade; s.insert(stu);
} cin>>grade1>>grade2; set<student>::reverse_iterator begin = s.rbegin(),end = s.rend(),i; for(i=begin;i!=end;++i)
{
if((*i).grade >= grade1 && (*i).grade <= grade2)
{
cout<<i->name<<" "<<i->ID<<endl;
flag = ;
}
} if(flag)
cout<<"NONE"<<endl;
}

PAT 甲级 1083 List Grades (25 分)的更多相关文章

  1. PAT 甲级 1028 List Sorting (25 分)(排序,简单题)

    1028 List Sorting (25 分)   Excel can sort records according to any column. Now you are supposed to i ...

  2. PAT 甲级 1020 Tree Traversals (25分)(后序中序链表建树,求层序)***重点复习

    1020 Tree Traversals (25分)   Suppose that all the keys in a binary tree are distinct positive intege ...

  3. PAT 甲级 1146 Topological Order (25 分)(拓扑较简单,保存入度数和出度的节点即可)

    1146 Topological Order (25 分)   This is a problem given in the Graduate Entrance Exam in 2018: Which ...

  4. PAT 甲级 1071 Speech Patterns (25 分)(map)

    1071 Speech Patterns (25 分)   People often have a preference among synonyms of the same word. For ex ...

  5. PAT 甲级 1063 Set Similarity (25 分) (新学,set的使用,printf 输出%,要%%)

    1063 Set Similarity (25 分)   Given two sets of integers, the similarity of the sets is defined to be ...

  6. PAT 甲级 1059 Prime Factors (25 分) ((新学)快速质因数分解,注意1=1)

    1059 Prime Factors (25 分)   Given any positive integer N, you are supposed to find all of its prime ...

  7. PAT 甲级 1051 Pop Sequence (25 分)(模拟栈,较简单)

    1051 Pop Sequence (25 分)   Given a stack which can keep M numbers at most. Push N numbers in the ord ...

  8. PAT 甲级 1048 Find Coins (25 分)(较简单,开个数组记录一下即可)

    1048 Find Coins (25 分)   Eva loves to collect coins from all over the universe, including some other ...

  9. PAT 甲级 1037 Magic Coupon (25 分) (较简单,贪心)

    1037 Magic Coupon (25 分)   The magic shop in Mars is offering some magic coupons. Each coupon has an ...

随机推荐

  1. 使用nginx作为webservice接口代理

    通常情况下,企业并不会直接开放系统接口给到外网,并且在企业内部同样有SOA或者ESB这样的接口统一管理的工具. 那么,大多数情况下,如果需要与外部系统,如云系统,或者其他企业的系统做接口时采取的方式如 ...

  2. Awesome Tools

    Awesome R: https://awesome-r.com/ (Chinese translation: http://www.ppvke.com/Blog/archives/40981) Aw ...

  3. request.getRealPath的替代方法

    在写上传小练习的时候,发现获得路径的request.getRealPath("")已经被画上线了,也就是不再建议使用. package controller; import jav ...

  4. sql查询练习

    #建学生信息表student create table student ( sno varchar(20) not null primary key, sname varchar(20) not nu ...

  5. python笔记12-字典

    1.定义字典#定义字典--字典里面的key是不能重复的info = { 'name':'xiaoming', 'sex':'nan', 'age':20, 'id':1,}2.字典取值 #取值:方法1 ...

  6. Centos7配置TiDB监控

    一: 1.1:http://192.168.1.12:3000/ 1.2:点击install Grafana wget https://dl.grafana.com/oss/release/grafa ...

  7. pass,break,continue的使用场景

    # ### 关键字的使用 pass / break / continue # pass 过 起到占位的作用 if 5 == 5: pass print(123) # break 只能应用在循环当中 用 ...

  8. 基于TCP的安卓服务器开发

    一.说明 前文介绍了基于安卓客户端的开发,在此基础上,进行少许改动即可开发出一款基于TCP的安卓服务器,理论知识请参见笔者上一篇博文,下面直接实践操作. 二.权限申明 <!--允许应用程序改变网 ...

  9. jdbc “贾琏欲执事”

    “贾琏欲执事” 1.加载驱动2.获取连接3.SQL语句4.执行SQL5.释放资源 示例: public void test_insert() { String driver="oracle. ...

  10. 【webdriver自动化】将163登录邮箱的操作封装成多个方法去执行

    login_info.txt: youxiang_99@163.com,XXXX youxiang_100@163.com,XXXX main.py: #注意:编码格式 #算法: (1)定义多个方法, ...