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;
}

最新文章

  1. 06. Web大前端时代之:HTML5+CSS3入门系列~HTML5 画布
  2. C#数组全解
  3. perl sub return 的作用
  4. Python的平凡之路(9)
  5. NSPredicate谓词
  6. Base64加密解密原理以及代码实现(VC++)
  7. SIMATIC IT HISTORIAN在烟用二醋酸纤维素生产中应用
  8. 摄像机(CCCamera)
  9. mybatis动态sql语句问题
  10. 灵玖Nlpir Parser智能挖掘汉语精准分词
  11. docker bulid命令
  12. spring注解驱动--组件注册
  13. MySQL中的数据类型以及完整性约束
  14. SlickMaster.NET 开源表单设计器快速使用指南
  15. Axiom3D:资源引用与加载基本流程.
  16. Python爬虫-什么是爬虫?
  17. jackson快速实现对象与json之间的转换
  18. ROS-PCQ基于IP的限速(总带宽上下行5M)
  19. 【校招面试 之 剑指offer】第18题 删除链表中的节点
  20. clipboard.js实现复制功能

热门文章

  1. jboss_log4j.xml配置
  2. Jenkins安装第一个插件和通过离线安装包进行安装
  3. git push 报504 (因提交文件内容过大而失败的解决方案)
  4. OpenGL入门1.2:渲染管线简介,画三角形
  5. SQL Server中使用SQL语句关闭数据库连接和删除数据库文件
  6. JavaScript BOM Cookie 的用法
  7. Docker Desktop for Windows 安装步骤
  8. 微软官方的.net系列文档
  9. Spring Cloud Netflix之Euraka Server注册中心
  10. lua脚本之钉钉免密登录