#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <algorithm> using namespace std; class Stu {
public:
char name[];
char id[];
int grade;
char gender;
}; bool my_cmp(const Stu* a, const Stu* b) {
return a->grade < b->grade;
} void print (vector<Stu*> &stu) {
int len = stu.size();
for (int i=; i<len; i++) {
printf("%s %d\n", stu[i]->name, stu[i]->grade);
}
} int main() {
vector<Stu*> male;
vector<Stu*> female;
int n = ;
scanf("%d", &n); for (int i=; i<n; i++) {
Stu* p = new Stu();
scanf("%s %c %s %d", p->name, &(p->gender), p->id, &(p->grade)); if (p->gender == 'M') {
male.push_back(p);
} else {
female.push_back(p);
}
}
sort(male.begin(), male.end(), my_cmp);
sort(female.begin(), female.end(), my_cmp); Stu* best = NULL;
Stu* worst= NULL; if (female.empty()) {
printf("Absent\n");
} else {
best = female[female.size() - ];
printf("%s %s\n", best->name, best->id);
}
if (male.empty()) {
printf("Absent\n");
} else {
worst = male[];
printf("%s %s\n", worst->name, worst->id);
}
if (worst == NULL || best == NULL) {
printf("NA\n");
} else {
printf("%d", best->grade - worst->grade);
}
return ;
}

我感觉自己已经成脑残了,竟然忘了传my_cmp

PAT 1036 Boys vs Girls的更多相关文章

  1. PAT 1036 Boys vs Girls[简单]

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

  2. PAT 1036 Boys vs Girls (25 分)

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

  3. PAT 1036 Boys vs Girls (25分) 比大小而已

    题目 This time you are asked to tell the difference between the lowest grade of all the male students ...

  4. PAT甲级:1036 Boys vs Girls (25分)

    PAT甲级:1036 Boys vs Girls (25分) 题干 This time you are asked to tell the difference between the lowest ...

  5. PAT 甲级 1036 Boys vs Girls (25 分)(简单题)

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

  6. PAT甲级——1036 Boys vs Girls

    1036 Boys vs Girls This time you are asked to tell the difference between the lowest grade of all th ...

  7. 1036 Boys vs Girls (25 分)

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

  8. 1036 Boys vs Girls (25分)(水)

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

  9. PAT甲题题解-1036. Boys vs Girls (25)-找最大最小,大水题

    题意:给出n个人的姓名.性别.ID.分数,让你找出其中哪个妹纸分数最高.哪个汉子分数最低.以及他们的差如果没有妹纸或者汉子,则对应输出Absent,差用NA代替. 就是for一遍找最大最小值,水题 # ...

随机推荐

  1. css flex 使内容 水平居中 的方法...

    刚开始以为是  justify-content : center 设置为 居中... 的确,,当 元素满了时 的确能 居中.但是 当只有一个元素时,这一个元素也会居中... 想了半天没找到方法..突然 ...

  2. fluent中UDF环境变量问题的三种解决方法

    方法一: 这种方式最简便,首选这种,但是有时会因为不明原因而不好使,我自己电脑刚开始用这种方式是行得通的,但是后来中途装过很多乱七八糟的软件,估计环境变量改乱了,这时候只能用第二种或者第三种方法.先说 ...

  3. JAVA数据结构--ArrayList动态数组

    在计算机科学中,动态数组,可扩展数组,可调整数组,动态表,可变数组或数组列表是一种随机存取可变大小列表数据结构,允许添加或删除元素.它提供许多现代主流编程语言的标准库.动态数组克服了静态数组的限制,静 ...

  4. 关于webpack 以及 webpack配置和常用插件的学习记录 (1)

    主要概念: Entry :   webpack的入口,构建的第一步从entry开始. Output :   输出,经过webpack处理后的得到最终想要的代码. Loader :   模块转换工具,把 ...

  5. [转] NOI, NOIP, IOI, ACM

    [From] http://blog.csdn.net/chenbean/article/details/38928243 NOI是教育部和中国科协委托中国计算机学会举办了全国青少年计算机程序设计竞赛 ...

  6. Web API 解决跨域问题

    一.跨域问题的由来 同源策略:出于安全考虑,浏览器会限制脚本中发起的跨站请求,浏览器要求JavaScript或Cookie只能访问同域下的内容. 正是由于这个原因,我们不同项目之间的调用就会被浏览器阻 ...

  7. 文献综述二:UML技术在行业资源平台系统建模中的应用

    一.基本信息 标题:UML技术在行业资源平台系统建模中的应用 时间:2015 出版源:Hans汉斯 文件分类:uml技术的应用 二.研究背景 为方便行业人员高效率地搜集专业知识,实现知识的共享.采用计 ...

  8. linux运维基础知识

    linux运维基础知识大全 一,序言 每一个微不足道的知识,也是未来的铺垫.每一份工作的薪资职位,也是曾经努力的结果. 二,服务器 1,运维人员工作职责: 1)保证数据不丢失:2)保证服务器24小时运 ...

  9. DP Intro - Tree DP Examples

    因为上次比赛sb地把一道树形dp当费用流做了,受了点刺激,用一天时间稍微搞一下树形DP,今后再好好搞一下) 基于背包原理的树形DP poj 1947 Rebuilding Roads 题意:给你一棵树 ...

  10. (转)超全整理!Linux性能分析工具汇总合集

    超全整理!Linux性能分析工具汇总合集 原文:http://rdc.hundsun.com/portal/article/731.html 出于对Linux操作系统的兴趣,以及对底层知识的强烈欲望, ...