#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. [Swift实际操作]九、完整实例-(5)创建BaseViewController作为控制器的基类

    本文将给项目中的所有视图控制器,创建一份基类.该基类用来定义一些共用的属性和方法. 首先在用来放置视图控制器类的文件夹上点击鼠标右键,打开右键 菜单. 选择[New File]创建文件选项. 在弹出的 ...

  2. centos7用docker安装mysql5.7.24后配置主从

    1)使用docker安装完成mysql5.7.24,我规划的是3台: 192.168.0.170(Master) 192.168.0.169(Slave) 192.168.0.168(Slave) 2 ...

  3. 怎样关闭adobe reader的自动更新

    https://jingyan.baidu.com/article/1612d5004390ebe20f1eee50.html

  4. AngularJs解决表达式闪烁的问题(ng-cloak)

    举例: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8 ...

  5. EasyUI学习笔记(一)EasyUI入门

    一.EasyUI下载 EasyUI官方下载地址:http://www.jeasyui.com/download/index.php,目前最新的版本是:jquery-easyui-1.7.2 解压后得到 ...

  6. ZOJ - 2402 DP方案数

    题意:给出m,序列第i位是第i-1位的至少2倍大,的求长度为n且每一位范围均在1-m的序列方案数 对求方案数做不到信手拈来的感觉,需要加强 用简单的预处理和最优子结构能优化到很不错的效率了 #incl ...

  7. nodejs下载器,通过chrome代理下载http资源

    var config={ //不想访问的东西,节约流量 "404":[ "http://qidian.qpic.cn/qdbimg" ], //奇数为需要下载的 ...

  8. GreenPlum 大数据平台--运维(一)

    .最后分析或真空或创建表或等... Select * from pg_stat_operations where schemaname='SCHEMA NAME ' and actionname in ...

  9. 段错误:使用opencv打开视频流

    段错误:使用opencv打开视频流时报这个错误 1 使用命令dmesg 发现是libavutil.so模块发生了错误. 如果是java端报错,可能如下: libavutil.so  ... av_di ...

  10. easyUI--datagrid 实现按键控制( enter tab 方向键 )

    1.表格定义时加上 onClickCell: onClickCell,2.定义列时加入编辑器3.引入 key.js 即可使用 enter 键 或者向下箭头 选中单元格下移 选中单元格上移 tab键 选 ...