题意:

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

trick:

测试点3格式错误因为输出的所有学生姓名和id后面都要换行,大概如果PAT没说不要输出多余的换行的话,就全都加个换行,说了就不加。。。。。

AAAAAccepted code:

 1 #define HAVE_STRUCT_TIMESPEC
2 #include<bits/stdc++.h>
3 using namespace std;
4 typedef struct student{
5 string name,id;
6 int grade;
7 };
8 student a[107];
9 bool cmp(student a,student b){
10 return a.grade>b.grade;
11 }
12 int main(){
13 ios::sync_with_stdio(false);
14 cin.tie(NULL);
15 cout.tie(NULL);
16 int n;
17 cin>>n;
18 for(int i=1;i<=n;++i)
19 cin>>a[i].name>>a[i].id>>a[i].grade;
20 int x,y;
21 cin>>x>>y;
22 if(x>y)
23 swap(x,y);
24 sort(a+1,a+1+n,cmp);
25 int flag=0;
26 for(int i=1;i<=n;++i)
27 if(a[i].grade>=x&&a[i].grade<=y){
28 cout<<a[i].name<<" "<<a[i].id<<"\n";
29 flag=1;
30 }
31 if(!flag)
32 cout<<"NONE"<<endl;
33 return 0;
34 }

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

  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 甲级 1028 List Sorting (25 分)(排序,简单题)

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

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

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

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

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

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

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

  6. 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 ...

  7. 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 ...

  8. 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 ...

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

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

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

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

随机推荐

  1. 1、Two Sum

    Given an array of integers, return indices of the two numbers such that they add up to a specific ta ...

  2. Hibernate:对象关系映射(一对一,一对多,多对一,多对多)

    如需转载,请说明出处:http://www.cnblogs.com/gudu1/p/6895610.html Hibernate通过关系映射来表示数据库中表与表之间的关系,关系映射可以通过两种方式:配 ...

  3. Linux, Nginx - Deepin linux手动安装nginx和出现的问题

    安装步骤 切换至root su 安装依赖库 sudo apt-get install build-essential && sudo apt-get install libtool s ...

  4. L2-3 名人堂与代金券

    题解 这题的话,每一个人都要占一个排名,即使排名并列了. 对于最后一个排名来说,即使人数超过了指定的k,也要加入. 代码 #include <bits/stdc++.h> using na ...

  5. eclipse非正常关闭,再打开后报错

    Previous operation has not finished; run 'cleanup' if it was interrupted 启动任务管理器,将javaw.exe进程杀死,然后重启 ...

  6. spring 配置

    在context中配置 如:在base-package指明一个包: <context:component-scan base-package="cn.edu.dao"/> ...

  7. Elasticsearch系列---shard内部原理

    概要 本篇我们来看看shard内部的一些操作原理,了解一下人家是怎么玩的. 倒排索引 倒排索引的结构,是非常适合用来做搜索的,Elasticsearch会为索引的每个index为analyzed的字段 ...

  8. 我的reshape观

    reshape(1,2)把结果分成1块,每一块2个元素 reshape(2,1)把结果分成2块,每一块1个元素 reshape(-1,1)把结果分成任意块,每一块1个元素 reshape(1,-1)把 ...

  9. kbhit函数说明

    kbhit,用来检测键盘是否被敲击.所以就有了他的名字:keyboard hit 当键盘有按键被按下时,kbhit函数就会返回一个非0值. 当我们在写某个程序时,希望读入一些字符,但是又不能停在那里只 ...

  10. Mac下ssh远程无密码登录

    入手Mac,对很多工具的使用都不太熟悉,这不,做web开发,登录远程服务器非常繁琐,想要去掉输入密码这个环节,找到网友的分享如下: http://www.cnblogs.com/shuaiwhu/ar ...