【PAT甲级】1083 List Grades (25 分)
题意:
输入一个正整数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 分)的更多相关文章
- 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 甲级 1028 List Sorting (25 分)(排序,简单题)
1028 List Sorting (25 分) Excel can sort records according to any column. Now you are supposed to i ...
- PAT 甲级 1020 Tree Traversals (25分)(后序中序链表建树,求层序)***重点复习
1020 Tree Traversals (25分) Suppose that all the keys in a binary tree are distinct positive intege ...
- PAT 甲级 1146 Topological Order (25 分)(拓扑较简单,保存入度数和出度的节点即可)
1146 Topological Order (25 分) This is a problem given in the Graduate Entrance Exam in 2018: Which ...
- PAT 甲级 1071 Speech Patterns (25 分)(map)
1071 Speech Patterns (25 分) People often have a preference among synonyms of the same word. For ex ...
- 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 ...
- 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 ...
- 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 ...
- PAT 甲级 1048 Find Coins (25 分)(较简单,开个数组记录一下即可)
1048 Find Coins (25 分) Eva loves to collect coins from all over the universe, including some other ...
- PAT 甲级 1037 Magic Coupon (25 分) (较简单,贪心)
1037 Magic Coupon (25 分) The magic shop in Mars is offering some magic coupons. Each coupon has an ...
随机推荐
- 安装破解pycharm2018版
1.安装2018版pycharm: 2.把破解补丁放在一个地方(目录无中文,无空格): 3.在 Pycharm安装目录的\bin目录下找到 pycharm.exe.vmoptions 和 pychar ...
- Lumen 实现接口 Captcha图片验证码功能
安装 composer require youngyezi/captcha 使用 新版的包已经删除了 session 支持,完全交给业务自由选择存储方式 个人觉得这样更方便来解耦业务,尤其 Lumen ...
- Redis 要学的
https://www.cnblogs.com/kismetv/p/8654978.html#t21 各个类型底层原理 慢查询 pipeline BitMaps 发布订阅 主从复制 psync psy ...
- 配置Mongodb
MS Windows: 常用命令: 查看帮助 mongod help/mongod -h 查看版本 mongod --version 启动/停止/重启服务 net start/stop/restart ...
- Install macOS High Sierra on Any Supported Intel-based PC
1.准备制作安装盘前的准备https://www.tonymacx86.com/threads/unibeast-install-macos-high-sierra-on-any-supported- ...
- Anaconda多环境Python
1. Create a new environment for 32bit Python 2.7: set CONDA_FORCE_32BIT=1 conda create -n py27_32 py ...
- ASP.NET + MVC5 入门完整教程三 (上) ---第一个MVC项目
https://blog.csdn.net/qq_21419015/article/details/80420815 第一个MVC应用程序 1创建MVC项目 打开VS ,File--新建--项目,选择 ...
- ubuntu---yolo报错darknet: ./src/cuda.c:36: check_error: Assertion `0' failed.
装好darknet后,直接测试的时候,报错: darknet: ./src/cuda.c:36: check_error: Assertion `0' failed.解决办法是打开yolov3.cfg ...
- [NLP]Transformer-XL论文解读
关于Transformer的具体内容,可以访问:https://www.cnblogs.com/mj-selina/p/12369797.html 简介 Transformer是Google Brai ...
- python 更换数据源
1.Win+R打开cmd输入%HOMEPATH%打开自己的HOMEPATH路径文件夹 2.在此路径下建立一个文件夹pip, 里边放一个文件pip.ini内容如下: [global] timeout = ...