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 ...
随机推荐
- web自动化框架之一介绍与环境搭建(Selenium+Eclipse+Python)
看到一篇环境搭建文章,详细又全面,这里就不一一重复了 http://blog.csdn.net/dyllove98/article/details/9390649 其它: 1.框架介绍 整个 ...
- ndk文件操作问题及小结
最近在做文件传输,发现在android下用f系列的C库函数去读取文件文件大小会受到2G大小的约束,查阅了很久,最后只能去看google的libc源码,发现了以下几个问题: 1.bionic的libc是 ...
- 【C#】字符串与字符数组
字符串与字符数组的相互转换. 字符串转换成字符数组: string ss="abcdefg"; char[] cc=ss.ToCharArray(); 字符数组转换成字符串 ...
- JQuery笔记:JQuery和JavaScript的联系与区别
来源:http://www.ido321.com/1019.html ps:LZ觉得这个标题有点大了,超出了能力范围,不喜勿碰.目前只记录LZ能力范围内的,日后持续补充. 一.JQuery对象和DOM ...
- 找不到或无法加载已注册的 .Net Framework Data Provide
在使用数据库的工程模式时,运行到下面代码第四行时,出现“找不到或无法加载已注册的 .Net Framework Data Provide”的错误! private DbProviderFactory ...
- PHP操作cookie函数:setcookie()与setrawcookie()
PHP setcookie() 函数向客户端发送一个 HTTP cookie.cookie 是由服务器发送到浏览器的变量.cookie 通常是服务器嵌入到用户计算机中的小文本文件.每当计算机通过浏览器 ...
- C#简单应用spring的例子
接口定义 namespace SpringDemo { interface IOper { void Say(); } } 此接口的两个实现 实现1 using System; namespace S ...
- HDU2066一个人的旅行(dijkstra)
一开始拿到这个题感觉floyd可能会超,还是写了写,果然1WA+1TLE,之后觉得用dijkstra试试看看S和D会不会比较小,还是1WA+1TLE,最后还是借鉴了别人的做法. 把他的家作为起点,与他 ...
- PHP 中运用 elasticsearch
PHP扩展安装 1. 环境要求:PHP_VERSION >= 5.3.9,composer工具 2. 在E盘新建文件夹命名为elastic,,拷贝composer.phar到 E:/e ...
- ASP.NET forms凭据设置和跳转的几种方法
string user = "userName"; //默认的第1种,超时时间是在web.cofig中forms设置的timeout,单位是分钟,生成的cookie和凭证超时时间一 ...