【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 ...
随机推荐
- linq和扩展方法
c#的扩展方法 1.必须是在一个非嵌套.非泛型的静态类中的静态方法 2.至少一个参数,第一个参数附加this,不能有其他修饰符如out.ref 3.第一个参数不能是指针类型 上面例子是自定义的一个扩展 ...
- vue图书小案例
小知识点: vue中计算属性有缓存(对象属性变化时才会更新),方法没有缓存,所以计算属性比方法效率高js中let有块级作用域,var没有块级作用域,所以var是有缺陷的this.letters[0] ...
- hadoop中遇到的各种错误记录
hadoop中namenode无法启动 转载链接:https://blog.csdn.net/love666666shen/article/details/74350358 使用pi ...
- 2020年算法设计竞赛 DP
链接:https://ac.nowcoder.com/acm/contest/3002/I来源:牛客网https://ac.nowcoder.com/acm/contest/3002/I 题目描述 & ...
- HTML学习(5)标题、水平线、注释
HTML 标题 标题(Heading)是通过 <h1> - <h6> 标签进行定义的. <h1> 定义最大的标题. <h6> 定义最小的标题. 注: 浏 ...
- 每天进步一点点------ISE 12.4的FPGA设计基本流程
基于ISE 12.4的FPGA设计基本流程 ISE是使用XILINX的FPGA的必备的设计工具,它可以完成FPGA开发的全部流程,包括设计输入.仿真.综合.布局布线.生成BIT文件.配置以及在线调试等 ...
- IIS7.x经典模式与集成模式
参考文档:http://book.51cto.com/art/200908/146143.htm 个人理解: 经典模式: 在IIS6中aspnet_isapi.dll只是ISAPI的一个实现,对asp ...
- Bugku - 好多压缩包 - Writeup
bugku - 好多压缩包 - Writeup M4x原创,转载请注明出处 这道题前前后后做了好几天,这里记录一下 题目 文件下载 分析 解压下载后的文件,发现有68个压缩文件,并且每个压缩文件里都有 ...
- bootstrap环境
<!doctype html> <html lang="en"> <head> <meta charset="utf-8&quo ...
- 1+x证书Web 前端开发初级——理论考试(试卷1)
1+x证书Web 前端开发初级——理论考试(试卷1) 一.单选题(每小题 2 分,共 30 小题,共 60 分) 1.HTML 语言中,设置表格中文字与边框距离的标签是() A.<table b ...