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 分)的更多相关文章

  1. 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 ...

  2. 【PAT甲级】1083 List Grades (25 分)

    题意: 输入一个正整数N(<=101),接着输入N个学生的姓名,id和成绩.接着输入两个正整数X,Y(0<=X,Y<=100),逆序输出成绩在x,y之间的学生的姓名和id. tric ...

  3. PAT 甲级 1083 List Grades (25 分)

    1083 List Grades (25 分) Given a list of N student records with name, ID and grade. You are supposed ...

  4. 1012 The Best Rank (25 分)

    1012 The Best Rank (25 分) To evaluate the performance of our first year CS majored students, we cons ...

  5. 1062 Talent and Virtue (25 分)

    1062 Talent and Virtue (25 分) About 900 years ago, a Chinese philosopher Sima Guang wrote a history ...

  6. 1036 Boys vs Girls (25 分)

    1036 Boys vs Girls (25 分) This time you are asked to tell the difference between the lowest grade of ...

  7. A1012 The Best Rank (25)(25 分)

    A1012 The Best Rank (25)(25 分) To evaluate the performance of our first year CS majored students, we ...

  8. PATA1012The Best Rank(25分)

    To evaluate the performance of our first year CS majored students, we consider their grades of three ...

  9. PAT 甲级 1062 Talent and Virtue (25 分)(简单,结构体排序)

    1062 Talent and Virtue (25 分)   About 900 years ago, a Chinese philosopher Sima Guang wrote a histor ...

随机推荐

  1. git使用cherry-pick和revert抢救错误代码提交

    大多数的新手在新接触git时都会出现这样的问题.代码写完了,提交到dev分支进行测试.一高兴忘记切回来,继续在dev分支开发,写完之后提交时猛的发现,我靠,我怎么在dev上面写代码,此时内心必然是一阵 ...

  2. 【MySQL】Mariadb主从复制

    Mariadb主从复制 环境配置: Master : 172.30.200.200 Slave : 172.30.200.204 架构图,如下: Master的配置: 1.binlog配置 [root ...

  3. python批量裁剪图片

    """用Pythonp批量裁剪图片""" from PIL import Imageimport matplotlib.pyplot as ...

  4. Python保存json文件并格式化

    使用json.dump()的时候设置一下indent参数的值就好了.比如json.dump(json_dict, f, indent=4), ensure_ascii=False,写入中文

  5. Spring自动注入,类型注入、名称注入(两种方式)

    参考: https://blog.csdn.net/qq_41767337/article/details/89002422 https://www.iteye.com/blog/breezylee- ...

  6. Java8新特性——Optional类的使用(有效的避免空指针异常)

    OPtional类的使用 概述 到目前为止,臭名昭著的空指针异常是导致Java应用程序失败的最常见原因.以前,为了解决空指针异常,Google公司著名的Guava项目引入了Optional类,Guav ...

  7. S-T-E-A-M Science Technology Engineering Art Mathematics 五种思维模式

    S-T-E-A-M五个英文字母分别代表 Science 科学,Technology 技术,Engineering 工程,Art 艺术以及 Mathematics 数学.它们并不是简单地整合原来的分科体 ...

  8. 5种IO模型、阻塞IO和非阻塞IO、同步IO和异步IO

    POSIX 同步IO.异步IO.阻塞IO.非阻塞IO,这几个词常见于各种各样的与网络相关的文章之中,往往不同上下文中它们的意思是不一样的,以致于我在很长一段时间对此感到困惑,所以想写一篇文章整理一下. ...

  9. SQL Server温故系列(0):导航目录

    创建本系列博文通用库表及数据的 SQL 语句:下载 SQL Server温故系列(0):导航目录 SQL Server温故系列(1):SQL 数据操作 CRUD 之增删改合 SQL Server温故系 ...

  10. MES系统如何帮助烟草行业管理生产流程

    与很多其他行业一样,烟草MES系统可以帮助卷烟企业实现智能生产.精益制造.快速实现烟草企业数字化车间的创建,助力企业实现改造升级,从而提升企业生产效率,降低生产成产.烟草行业得MES者得天下. 烟草行 ...