A1083. List Grades
Given a list of N student records with name, ID and grade. You are supposed to sort the records with respect to the grade in non-increasing order, and output those student records of which the grades are in a given interval.
Input Specification:
Each input file contains one test case. Each case is given in the following format:
N
name[1] ID[1] grade[1]
name[2] ID[2] grade[2]
... ...
name[N] ID[N] grade[N]
grade1 grade2
where name[i] and ID[i] are strings of no more than 10 characters with no space, grade[i] is an integer in [0, 100], grade1 and grade2 are the boundaries of the grade's interval. It is guaranteed that all the grades are distinct.
Output Specification:
For each test case you should output the student records of which the grades are in the given interval [grade1, grade2] and are in non-increasing order. Each student record occupies a line with the student's name and ID, separated by one space. If there is no student's grade in that interval, output "NONE" instead.
Sample Input 1:
4
Tom CS000001 59
Joe Math990112 89
Mike CS991301 100
Mary EE990830 95
60 100
Sample Output 1:
Mike CS991301
Mary EE990830
Joe Math990112
Sample Input 2:
2
Jean AA980920 60
Ann CS01 80
90 95
Sample Output 2:
NONE
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
typedef struct{
char name[];
char id[];
int grade;
}info;
bool cmp(info a, info b){
return a.grade > b.grade;
}
info stu[];
int main(){
int N, high, low, cnt = ;
scanf("%d", &N);
for(int i = ; i < N; i++)
scanf("%s %s %d", stu[i].name, stu[i].id, &(stu[i].grade));
sort(stu, stu + N, cmp);
scanf("%d%d", &low, &high);
for(int i = ; i < N; i++){
if(stu[i].grade >= low && stu[i].grade <= high){
printf("%s %s\n", stu[i].name, stu[i].id);
cnt++;
}
}
if(cnt == )
printf("NONE");
cin >> N;
return ;
}
A1083. List Grades的更多相关文章
- 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 ...
- A1083 List Grades (25 分)
Given a list of N student records with name, ID and grade. You are supposed to sort the records with ...
- PAT甲级——A1083 List Grades
Given a list of N student records with name, ID and grade. You are supposed to sort the records with ...
- PAT_A1083#List Grades
Source: PAT A1083 List Grades (25 分) Description: Given a list of N student records with name, ID an ...
- PAT甲级题解分类byZlc
专题一 字符串处理 A1001 Format(20) #include<cstdio> int main () { ]; int a,b,sum; scanf ("%d %d& ...
- PAT1083:List Grades
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 ...
- Taking water into exams could boost grades 考试带瓶水可以提高成绩?
Takeing a bottle of water into the exam hall could help students boost their grades, researchers cla ...
- PAT 1083 List Grades[简单]
1083 List Grades (25 分) Given a list of N student records with name, ID and grade. You are supposed ...
随机推荐
- C#抽象类跟接口
抽象类描述的是一个什么东西,属性. 抽象类是对类的抽象,描述是什么 抽象类,继承后重写接口描述的是他做什么,行为.接口是对行为的抽象,描述做什么 ,进行继承后实行接口
- 行业干货-如何逆向解决QT程序汉化中乱码问题
前言 “一款QT开发的国外软件,大概率是没有做中文支持的,所以你汉化中,不论怎么设置编码都一定是乱码.面对这个问题,你去互联网上找答案,答案却大多是复制粘贴的开发中解决乱码的文章,可是我们是要逆向中解 ...
- 分布式监控系统Zabbix-图形集中展示插件Graphtree安装笔记
Zabbix想要集中展示图像,唯一的选择是screen,后来zatree解决了screen的问题,但性能不够好.Graphtree 由OneOaaS开发并开源出来,用来解决Zabbix的图形展示问题, ...
- this.$http.post ||this.$http.put||vue 获取url参
getClasslist() { this.$http.get('/xxxxx/childlist', { params: { ServiceUnitId: localStorage.getItem( ...
- 使用代理创建连接池 proxyPool
配置文件properties url=jdbc:mysql://127.0.0.1:3306/mine?characterEncoding=UTF-8 user=root password=1234 ...
- git学习笔记——廖雪峰git教程
OK,先附上教程--廖雪峰的官方网站 友情连接:git官网 简介 这里我只想引用他的原文: Linus可以向BitMover公司道个歉,保证以后严格管教弟兄们,嗯,这是不可能的.实际情况是这样的: L ...
- Quartz应用与集群原理分析
Quartz在CRM中的应用场景: https://tech.meituan.com/mt-crm-quartz.html https://www.mtyun.com/library/mt-crm-q ...
- jQuery中click事件多次触发解决方案
jQuery 中元素的click事件中绑定其他元素的click事件. 因为jQuery中的click事件会累计绑定,导致事件注册越来越多. 解决方案: 1.能够避开,避免把click事件绑定到其他元素 ...
- CentOS virt-manager 安装Win2008r2的一种GUI方法
1. 必须在物理机上面安装CentOS机器. 安装方法上一个blog里面简单写过. 注意一点,重复安装时 总是提示no disk found 我的解决办法使用 windows 安装盘 格式化了下磁盘重 ...
- python模块_多重继承的MRO
MRO(Method Resolution Order):方法解析顺序.Python语言包含了很多优秀的特性,其中多重继承就是其中之一,但是多重继承会引发很多问题,比如二义性,Python中一切皆引用 ...