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. etcd+https部署

    关闭防火墙 关闭selinux 下载所需的包(cfssl,生成证书工具) mkdir /usr/local/src/etcd/ cd /usr/local/src/etcd/ wget https:/ ...

  2. 《一起学mysql》2

    事务   爸妈让往他们银行卡里转点儿钱,可是我这钱全在支付宝里,爸妈又没有支付宝,只能从支付宝里转给他 们了,假如转账过程中,支付宝扣款成功了,但是银行系统崩溃了,钱没转进去,这咋整?我的大洋就这样 ...

  3. 十二、Spring之IOC容器初始化

    Spring之IOC容器初始化 前言 在前面我们分析了最底层的IOC容器BeanFactory,接着简单分析了高级形态的容器ApplicationContext,在ApplicationContext ...

  4. mysql 实现经纬度排序查找功能

    需求如下: 商品有多个门店,用户使用App时需要查找附近门店的商品,商品要进行去重分页. 思路: 1.确认mysql自带经纬度查询函数可以使用. 2.该需求需要利用分组排序,取每个商品最近门店的商品i ...

  5. 【测试方法】Web测试中bug定位基本方法

    知识总结:Web测试中bug定位基本方法 涉及知识点:测试方法 在web测试过程中,经常会遇到页面中内容或数据显示错误,甚至不显示,第一反应就是BUG,没错,确实是BUG.进一步了解这个BUG的问题出 ...

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

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

  7. ASP.NET list<object> OBJECT.clean()会清空session['OBJECT']的值的问题

    public partial class 测试 : System.Web.UI.Page { static List<Item> allAnswer= new List<Item&g ...

  8. 深入浅出《设计模式》之外观模式(C++)

    前言 模式介绍 外观模式相比较之下比较简单,模式设计中定义是为子系统中的一组接口提供一个一致的界面,此模式定义了一个高层接口,这个接口是的这一子系统更加容易使用. 如果不理解呢,简单些说就是外观模式提 ...

  9. 多任务学习Multi-task-learning MTL

    https://blog.csdn.net/chanbo8205/article/details/84170813 多任务学习(Multitask learning)是迁移学习算法的一种,迁移学习可理 ...

  10. Django框架(二十)-- Django rest_framework-权限组件

    一.权限组件的使用 # 用户信息表 class UserInfo(models.Model): name = models.CharField(max_length=32) # 写choice use ...