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. pat1067. Sort with Swap(0,*) (25)

    1067. Sort with Swap(0,*) (25) 时间限制 150 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue G ...

  2. 19.CentOS7下PostgreSQL安装过程

    CentOS7下PostgreSQL安装过程 装包 sudo yum install postgresql-server postgresql-contrib 说明: 这种方式直接明了,其他方法也可以 ...

  3. valueOf() 和 toString()

    valueOf():如果存在任意原始值,返回最适合该对象类型的原始值. toString():将该对象的原始值以字符串形式返回. 这两个方法一般是交由JS去隐式调用,以满足不同的运算情况.  举个栗子 ...

  4. html的语法 3

    <html> <head> <title>这是第一节课网页标题</title> <!--meta charset="UTF-8" ...

  5. css 03

    DIV+CSS盒子模型 一.盒子模型css height width padding 内边距 margin  外边距 border 1.margin 外边距 margin-top:15px; marg ...

  6. Hibernate笔记3--多表操作-导航查询

    一.一对多操作 1.构造实体类及编写配置文件:     一方:  // 一个Customer对应多个linkman private Set<Linkman> linkmans = new ...

  7. bank conflct 一句话总结

    由于最新的多播模式区别于原来的广播模式,原来同一个warp不同线程访问同一个bank的相同地址不再是bank conflict, 现在总结为:只要同一个 warp 的不同线程会访问到同一个 bank ...

  8. centos6.2安装内核

    http://vault.centos.org/6.2/updates/Source/SPackages/ yum install rpm-build redhat-rpm-config unifde ...

  9. 关于第三方dll,ocx开发的思考

    A问题: 最近有个工作,要集成一套老的指纹考勤机器到现在考勤系统(web系统)中,问题出现时老的机器只有ocx可用,没有可用的dll:原本以为简单的第三方调用就ok了,可是ocx不能被承载,在实现上费 ...

  10. U盘小偷——C++实现U盘插入检测和文件扫描拷贝

    前几天女朋友说老师上课的PPT不共享,没法复习,想着写个U盘小偷拷贝PPT来着,后来觉得这样的行为这是不对的,万一不小心复制了老师的专利啥的,或者一些不可描述的东西,就闹大了. 虽然没有采取实际行动, ...