【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 ...
随机推荐
- [P4549] 【模板】裴蜀定理 - GCD
__gcd真好用 #include <bits/stdc++.h> using namespace std; int main() { int n,x,a=0; cin>>n; ...
- 题解 P4289 【[HAOI2008]移动玩具】
题目地址:https://www.luogu.com.cn/problem/P4289 题解原地址:https://createsj.blog.luogu.org/solution-p4289 让我们 ...
- java 集合与数组的互转方法,与源码分析
前言 java数组与集合需要互相转换的场景非常多,但是运用不好还是容易抛出UnSupportedOperationException.下面讲解一下互转的方法,以及结合源码分异常产生的原因 集合转数组 ...
- django入门与实践(续)
完善博客 博客页面设计 页面概要 1.博客主页面 主页面内容 文章标题列表,超链接 发表博客按钮(超链接) 列表编写思路 取出数据库中所有文章对象 将文章对象们打包成列表,传递到前端 前端页面把文章以 ...
- python之路xml模块补充
创建一个子节点一共有三个方式 创建一个子节点2.3
- dea创建Maven工程用c3p0连接数据库报错java.sql.SQLException: Connections could not be acquired from the underlying
idea java.sql.SQLException: Connections could not be acquired from the underlying database! 转载自:ht ...
- 用户 'sa' 登录失败。该用户与可信 SQL Server 连接无关联'。错误代码:18452 解决办法
原文:https://blog.csdn.net/wuxianwei/article/details/6330270 SQLSERVER 2005采用'SQLSERVER身份验证'去登录, 出错的原因 ...
- bootstrap联动校验(转载)
接触bootstrapvalidator时间不久,最近需要多个字段共同验证,网上查了一下未找到,查阅api文档,发现确实可以实现. 先看dom <div class="form-gro ...
- java 中使用logback日志,并实现日志按天分类压缩保存。
以maven项目作为构建工具为例,首先引入使用logback需要的3个依赖,需要注意使用logback是需要引入slf4j-api的,因为logback是基于slf4j的 <!--logback ...
- JS字符串的不可变性
js中的字符串特性->不可变性,字符串的值是不可变的 1.改变字符串中的字符 var str = "hello"; str[1] = "W"; conso ...