A1083 List Grades (25)(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

AC代码

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#define maxn 50
struct Student {
char name[11];
char id[11];
int grade;
}stu[maxn];
int cmp(const void*a, const void*b) {
// struct Student*aa=(Student*)a;
// struct Student*bb=(Student*)b;
struct Student*aa=a;
struct Student*bb=b;
return aa->grade < bb->grade ? 1:-1;//为实现成绩降序,c++ 是>,c语言则是<,1<2返回正值,1==2返回0,1>2,返回负值
}
int main() {
int n, left, right;
scanf("%d", &n);
for(int i = 0; i < n; i++) {
scanf("%s %s %d", stu[i].name, stu[i].id, &stu[i].grade);
}
scanf("%d%d", &left, &right);
qsort(stu,n,sizeof(stu[0]), cmp);
bool flag = false;
for(int i = 0; i < n; i++) {
if(stu[i].grade >= left && stu[i].grade <= right) {
printf("%s %s\n", stu[i].name, stu[i].id);
flag = true;
}
}
if(flag == false) {
printf("NONE\n");
}
return 0;
}

A1083 List Grades (25)(25 分)的更多相关文章

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

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

  2. 怎么设置BarTender中二维码大小为25*25

    有小伙伴近期问了小编一个问题,说客户需要25*25大小的QR Code二维码,用BarTender怎么做出来?想要指定条形码的大小,还得BarTender符号与版本选项来帮忙.本文小编就来给大家详细讲 ...

  3. JAVA题目:正整数n若是其平方数的尾部,则称n为同构数 如:5*5=25, 25*25=625 问: 求1~99中的所有同构数

    1 /*题目:正整数n若是其平方数的尾部,则称n为同构数 2 如:5*5=25, 25*25=625 3 问: 求1~99中的所有同构数 4 */ 5 //分析:将1-99分为1-9和10-99,用取 ...

  4. A1083 List Grades (25 分)

    Given a list of N student records with name, ID and grade. You are supposed to sort the records with ...

  5. [C++]PAT乙级1010. 一元多项式求导 (25/25)

    /* 1010. 一元多项式求导 (25) 设计函数求一元多项式的导数.(注:x^n(n为整数)的一阶导数为n*x^n-1.) 输入格式: 以指数递降方式输入多项式非零项系数和指数(绝对值均为不超过1 ...

  6. [C++]PAT乙级1005. 继续(3n+1)猜想 (25/25)

    /* 1005. 继续(3n+1)猜想 (25) 卡拉兹(Callatz)猜想已经在1001中给出了描述.在这个题目里,情况稍微有些复杂. 当我们验证卡拉兹猜想的时候,为了避免重复计算,可以记录下递推 ...

  7. A1083. List Grades

    Given a list of N student records with name, ID and grade. You are supposed to sort the records with ...

  8. PAT甲级——A1083 List Grades

    Given a list of N student records with name, ID and grade. You are supposed to sort the records with ...

  9. PAT 甲级 1006 Sign In and Sign Out (25)(25 分)

    1006 Sign In and Sign Out (25)(25 分) At the beginning of every day, the first person who signs in th ...

随机推荐

  1. PHP面向对象编程一

    php面向对象编程(一)   类与对象关系: 类就像一个人类的群体 我们从类中实例化一个对象 就像是制定一个人. 面向对象程序的单位就是对象,但对象又是通过类的实例化出来的,所以我们首先要做的就是如何 ...

  2. 白话SpringCloud | 第零章:前言

    说在前面 大清早醒来,觉得睡不着了.还是起来,写写博客.但最后发现关于SpringBoot的安全相关的还是比较多内容的,也比较专业,怕是一个多小时完不成的,也罢,那就来写写关于SpringCloud前 ...

  3. 最简实例演示asp.net5中用户认证和授权(1)

    asp.net5中,关于用户的认证和授权提供了非常丰富的功能,如果结合ef7的话,可以自动生成相关的数据库表,调用也很方便. 但是,要理解这么一大堆关于认证授权的类,或者想按照自己项目的特定要求对认证 ...

  4. C 碎片二 数据类型

    一.概述 C 语言包含的数据类型如下图所示: 二.各种数据类型介绍 2.1 整型 整形包括短整型.整形和长整形. 2.1.1 短整形 short a=1; 2.1.2 整形 一般占4个字节(32位), ...

  5. Python开发环境Wing IDE搜索工具介绍

    Wing IDE编辑器的搜索工具提供了一个基于友好GUI的搜索和替换工具. 某些情况下搜索可能会跨越整个文件,也有可能被限制到当前所选择的区域:可以区分大小写,也可以设置为不区分:可以被限制为只匹配整 ...

  6. Oracle Form个性化案例(一)

    业务场景: 现有Form A,需通过A中的菜单栏中调用另一Form B,需将某值作为参数传入Form B中:

  7. web调试的一些小技巧

    1.不带缓存的刷新,用于刷新css或者js:Ctrl+F5 待续...

  8. java poi读取excel公式,返回计算值(转)

    http://blog.csdn.net/CYZERO/article/details/6573015 经测试,确实可以 1 package hrds.zpf.poi;  2  3  import o ...

  9. Aizu 2456 Usoperanto (贪心)

    贪心,对于一个修饰关系可以连一条有向边,在合并的时候,子节点的序列一定是连续安排的,因为如果有交叉,交换以后一定更优. 然后一个序列一个序列的考虑,长度短的应该在前面,否则同样交换以后更优.因此排序以 ...

  10. Aizu 2301 Sleeping Time(概率,剪枝)

    根据概率公式dfs即可,判断和区间[T-E,T+E]是否有交,控制层数. #include<bits/stdc++.h> using namespace std; int K,R,L; d ...