PAT 甲级 A1083 (2019/02/17)

#include<cstdio>
#include<cstring>
#include<algorithm>         // STL
using namespace std;        //使用sort()函数必须加上
const int MAXN = 50;
struct Student{
    char name[15];
    char id[15];
    int score;
}stu[MAXN];
bool cmp(Student a, Student b){
    return a.score > b.score;   //按照分数排序,从大到小
}
int main(){
    int n;
    scanf("%d", &n);        //总人数
    for(int  i = 0; i < n; i++){
        scanf("%s %s %d", stu[i].name, stu[i].id, &stu[i].score);
    }
    sort(stu, stu + n, cmp);        //排序
    int start, end;
    bool flag = false;
    scanf("%d %d", &start, &end);
    for(int  i = 0; i < n; i++){
        if(stu[i].score >= start && stu[i].score <= end){
            printf("%s %s\n", stu[i].name, stu[i].id);
            flag = true;
        }
    }
    if(flag == false){
        printf("NONE\n");   //出错了,题目里是大写,而我写成了None
    }
    return 0;
}

原文地址:https://www.cnblogs.com/zjsaipplp/p/10425248.html

时间: 2024-08-30 02:37:21

PAT 甲级 A1083 (2019/02/17)的相关文章

PAT 甲级 A1025 (2019/02/17)

#include<cstdio> #include<cstring> #include<algorithm> using namespace std; const int maxn = 30010; struct Student{ char id[15]; int score; int local_number; int local_rank; }stu[maxn]; bool cmp(Student a, Student b){ if(a.score != b.sco

PAT 甲级 A1028 (2019/02/17)

#include<cstdio> #include<cstring> #include<algorithm> using namespace std; const int MAXN = 100010; struct Student{ int id; char name[10]; int score; }stu[MAXN]; bool cmp1(Student a, Student b) { return a.id < b.id; //从小到大 } bool cmp

PAT 甲级 A1055 (2019/02/17)

#include<cstdio> #include<cstring> #include<algorithm> // STL using namespace std; //使用sort()函数必须加上 const int MAXN = 100010; struct TH{ char name[15]; int age; int money; }th[MAXN], valid[MAXN]; int Age[MAXN] = {0}; //某年龄人数,下标代表人数 bool c

PAT甲级【2019年3月考题】——A1158 TelefraudDetection【25】

Telefraud(电信诈骗) remains a common and persistent problem in our society. In some cases, unsuspecting victims lose their entire life savings. To stop this crime, you are supposed to write a program to detect those suspects from a huge amount of phone c

PAT甲级1005 Spell It Right

题目:PAT甲级 1005 题解:水题.看到题目的第一时间就在想一位一位的mod,最后一加一转换就完事了.结果看到了N最大为10的100的次方,吓得我赶紧放弃这个想法... 发现碰到这种情况用字符串十分好用,这道题应该考察的就是这一点.大致思路就是把数字的每一位放到字符串中,然后通过ASCII码得到每一位的相加结果num,然后把num一位一位的放到stack中,使用stack是因为它先进先出的特性,最后输出就行了. 代码: 1 #include<cstdio> 2 #include<qu

【谜客帝国】第147届月思主擂谜会(2019.02.15)

 [谜客帝国]第147届月思主擂谜会(2019.02.15) 主持计分:东东 1.“人在中天日月间”(9笔字)春/月思 [注:面出陈孚<开平即事二首>,“势超大地山河上,-.”] 2. 玉漏声中烟气袅(3字法国奢侈品牌)YSL/月思 3. 双双相念初相爱(2字著名动漫人物)菜菜/月思 4.“数点燕云州外.雪霜威”(足球用语二,4+3)4132.451/月思 [注:面出余文<相见欢>,“登高望断龙旗,未曾归.几度中原北定,梦依稀.朔风乱,胡尘漫,掩斜晖.-.”] 5.“十载同心如一人

PAT甲级考前整理

终于在考前,刷完PAT甲级130道题目,不容易!!!每天沉迷在刷题之中而不能超脱,也是一种境界.PAT甲级题目总的说卡题目的比较多,卡测试点的比较少,有些题目还会有题意混淆,这点就不吐槽了吧.静下心来耍这130道题,其实磨练的是一种态度与手感,养成的是一种习惯.热爱AC没有错!! 130道题目主要的考点: 1.排序:快速排序,直接插入排序,希尔排序,分治排序,堆排序. 2.图论:拓扑排序.最短路径.深度搜索.广度搜索. 3.树:树的遍历.完全二叉树.AVL. 4.其他:并查集,模拟,哈希.背包.

解题报告 smoj 2019初二创新班(2019.3.17)

目录 解题报告 smoj 2019初二创新班(2019.3.17) T1:找玩具 题目描述 题意转化 分析 代码 优化(代码复杂度) T2:闯关游戏 题目描述 分析 代码 T3:子数组有主元素 题目描述 分析 代码(\(O(nm\log n)\)) 优化 代码(\(O(nm)\)) 解题报告 smoj 2019初二创新班(2019.3.17) 时间:2019.3.21 T1:找玩具 题目描述 在游戏开始之前,游戏大师在房间的某些地方隐藏了N个玩具.玩具编号为1到N.您的任务是尽可能多地找到这些玩

PAT甲级考试题库1001 A+B Format 代码实现及相关知识学习

准备参加九年九月份的PAT甲级证书考试,对网站上的题目进行总结分析: 1001题 A+B Format (20 分) Calculate a+b and output the sum in standard format -- that is, the digits must be separated into groups of three by commas (unless there are less than four digits). 计算a+b的值并以一定格式输出其和sum(数字需要