A1083 List Grades (25 分)
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
开始技术总结:
第一点就是初始化数组或是结构体的时候,大小要用常量,不能够使用输入量初始化
还有就是中文的括号注意一点
参考代码:
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;
const int MAXN = 50;
struct Student {
char ID[11];
char name[11];
int grade;
}student[MAXN];
bool cmp(Student a, Student b) {
if (a.grade != b.grade) return a.grade > b.grade;
}
int main(){
int grade1, grade2;
int N;
scanf("%d", &N);
for (int i = 0; i < N; i++) {
scanf("%s%s%d", student[i].name, student[i].ID, &student[i].grade);
}
scanf("%d%d", &grade1, &grade2);
sort(student, student + N, cmp);
int flag = 0;//用来标记是否又符合条件的同学,0表示没有
for (int j = 0; j < N; j++) {
if (student[j].grade <= grade2 && student[j].grade >= grade1) {
printf("%s %s\n", student[j].name, student[j].ID);
flag = 1;
}
}
if (flag == 0) {
printf("NONE");
}
system("pause");
return 0;
}
A1083 List Grades (25 分)的更多相关文章
- 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 ...
- 【PAT甲级】1083 List Grades (25 分)
题意: 输入一个正整数N(<=101),接着输入N个学生的姓名,id和成绩.接着输入两个正整数X,Y(0<=X,Y<=100),逆序输出成绩在x,y之间的学生的姓名和id. tric ...
- PAT 甲级 1083 List Grades (25 分)
1083 List Grades (25 分) Given a list of N student records with name, ID and grade. You are supposed ...
- 1012 The Best Rank (25 分)
1012 The Best Rank (25 分) To evaluate the performance of our first year CS majored students, we cons ...
- 1062 Talent and Virtue (25 分)
1062 Talent and Virtue (25 分) About 900 years ago, a Chinese philosopher Sima Guang wrote a history ...
- 1036 Boys vs Girls (25 分)
1036 Boys vs Girls (25 分) This time you are asked to tell the difference between the lowest grade of ...
- A1012 The Best Rank (25)(25 分)
A1012 The Best Rank (25)(25 分) To evaluate the performance of our first year CS majored students, we ...
- PATA1012The Best Rank(25分)
To evaluate the performance of our first year CS majored students, we consider their grades of three ...
- PAT 甲级 1062 Talent and Virtue (25 分)(简单,结构体排序)
1062 Talent and Virtue (25 分) About 900 years ago, a Chinese philosopher Sima Guang wrote a histor ...
随机推荐
- win10 x64 VS2017 PJSIP 视频通话编译流程
win10 x64 VS2017 PJSIP 视频通话编译流程 1. 下载PJSIP源码 PJSIP源码下载地址:https://www.pjsip.org/ 2. 阅读一遍官方的文档 文档地址:ht ...
- D3力布图绘制--基本方法
本文主要结合案例记录使用D3.js绘制力布图的基本方法 样例显示 基本配置 this.force = d3.layout .force() .size([this.width, this.height ...
- linux 用du查看硬盘信息
linux 用du查看硬盘信息 <pre>[root@iZ238qupob7Z web]# df -hFilesystem Size Used Avail Use% Mounted on/ ...
- windowsServer ------ 安装IIS
1.找到服务器管理器,点击添加角色,一步步执行 2.添加IIS 相关组件 勾选web服务器 下一步 将web服务iis 相关组件全部勾选,ftp 可不选 选择好后安装 等一会 关闭 可以查看到所安装角 ...
- AngleSharp 实战(05)之遍历内部子元素(x)元素,尝试着获取元素的 Attr 和 InnerText
直接贴代码了: using System; using System.Linq; using System.Threading.Tasks; using AngleSharp; using Angle ...
- Entity Framework 6 中如何获取 EntityTypeConfiguration 的 Edm 信息?(一)
1. 案例1 - 类型和表之间的EF代码优先映射 从EF6.1开始,有一种更简单的方法可以做到这一点.有关 详细信息,请参阅我的新EF6.1类型和表格之间的映射. 直接贴代码了 从EF6.1开始,有一 ...
- SAP PI开发手册-ERP发布服务供外部系统调用(sproxy代理类)
转自:https://www.cnblogs.com/fanjb/p/10829858.html 一. 接口内容 接口详细信息 1. 字段对应关系 发送字段对应关系 返回字段对应关系 2. ...
- ASP.Net Core使用Ajax局部更新
由于目前ASP.NET Core中没有提供Ajax帮助器,所以参照 上一篇帖文,使用data-ajax-*属性来使用jQuery Unobtrusive Ajax功能实现HTML的局部页面元素更新. ...
- .net core 发布到iis问题 HTTP Error 500.30 - ANCM In-Process Start Failure
1. 没有在Program里配置IIS webBuilder.UseIIS(); 2. StartupProduction 里AutoFac容器注入错误和新版的CORS中间件已经阻止使用允许任意Ori ...
- 海关单一窗口程序出现网络/MQ问题后自动修复处理
单一窗口切换了2年多了,由于RabbitMQ或者网络的不稳定,或者升级或者网络调整,等等诸多问题导致了海关单一窗口程序会不定期的出现文件及回执自动处理的作业停止的问题. 最近终于想明白了,把日志监控起 ...