1083. List Grades (25)
the problem is from PAT,which website is http://pat.zju.edu.cn/contests/pat-a-practise/1083
and the source code is as followed.
/*
firstly: sort the array using the algorithm "sort"
secondly: traverse all the possible answer and find the most suitable one.
*/
#include<iostream>
#include<vector>
#include<string>
#include<algorithm> using namespace std; struct record
{
string name;
string id;
int grade;
}; bool cmp(record x,record y)
{
return x.grade > y.grade;
} int main()
{
int n;
record temp;
vector<record> v;
cin>>n;
while (n--)
{
cin>>temp.name>>temp.id>>temp.grade;
v.push_back(temp);
}
int low,high;
cin>>low>>high; sort(v.begin(),v.end(),cmp);
int count = ;
for (int i = ; i < v.size(); i++)
{ if (v[i].grade>=low && v[i].grade <= high)
{
cout<<v[i].name<<" "<<v[i].id<<endl;
count += ;
}
}
if (count == )
{
cout<<"NONE"<<endl;
} }
this one is easy.and it doesn’t need to talk too much. If there are something to be noticed ,
maybe i think we should notice the boundery.
1083. List Grades (25)的更多相关文章
- 【PAT甲级】1083 List Grades (25 分)
题意: 输入一个正整数N(<=101),接着输入N个学生的姓名,id和成绩.接着输入两个正整数X,Y(0<=X,Y<=100),逆序输出成绩在x,y之间的学生的姓名和id. tric ...
- PAT (Advanced Level) 1083. List Grades (25)
简单排序. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #i ...
- 1083. List Grades (25)-简单的排序
给定区间[L,R],给出在这区间之内的学生,并且按照他们的成绩非升序的顺序输出. #include <iostream> #include <cstdio> #include ...
- pat1083. List Grades (25)
1083. List Grades (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Given a l ...
- 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 1083 List Grades[简单]
1083 List Grades (25 分) Given a list of N student records with name, ID and grade. You are supposed ...
- A1083 List Grades (25)(25 分)
A1083 List Grades (25)(25 分) Given a list of N student records with name, ID and grade. You are supp ...
- 1083 List Grades
Given a list of N student records with name, ID and grade. You are supposed to sort the records with ...
- PAT 甲级 1083 List Grades
https://pintia.cn/problem-sets/994805342720868352/problems/994805383929905152 Given a list of N stud ...
随机推荐
- mapreduce优化总结
集群的优化 1.合理分配map和reduce任务的数量(单个节点上map任务.reduce任务的最大数量) 2.其他配置 io.file.buffer.size hadoop访问文件的IO操作都需要通 ...
- hashtable,hashMap,vector和ArrayList
关于vector,ArrayList,hashMap和hashtable之间的区别 vector和ArrayList: 线程方面: vector是旧的,是线程安全的 ArrayList是java ...
- bzoj 3931 [CQOI2015]网络吞吐量(最短路,最大流)
[题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=3931 [题意] 只能通过1-n的最短路,求网络最大流 [思路] 分别以1,n为起点做最 ...
- 关于登录的会话控制, 终极解决方案 - chunyu
登录是用cookie还是session实现,一直有争议,普遍认为session更安全,可是有些功能,用cookie最方便也最高效,比如“记住我一周”. cookie还是session,我的答案是两 ...
- Codevs No.1052 地鼠游戏
2016-05-31 18:22:32 题目链接: 地鼠游戏 Codevs No.1245 题目大意: 打地鼠,一开始所有地鼠都出现,但是维持的时间(s)和击中所得的积分各不同,求出采用最优策略(1s ...
- leetcode@ [355] Design Twitter (Object Oriented Programming)
https://leetcode.com/problems/design-twitter/ Design a simplified version of Twitter where users can ...
- GDB中应该知道的几个调试方法
七.八年前写过一篇<用GDB调试程序>,于是,从那以后,很多朋友在MSN上以及给我发邮件询问我关于GDB的问题,一直到今天,还有人在问GDB的相关问题.这么多年来,有一些问题是大家反复在问 ...
- 在Windows Server 下安装 Oracle 11G 的一般步骤
- homework07
我阅读的: http://www.cnblogs.com/zhuyp1015/category/370450.html http://blog.csdn.net/hzyong_c/article/de ...
- java的math常用方法
鉴于java求整时欲生欲死,整理常用math如下: 1: java取整 a:floor向下取整 用法:Math.floor(num) Math.floor(1.9)//1 ...