#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. Docker安装FastDFS

    什么是FastDFS? FastDFS 是用 c 语言编写的一款开源的分布式文件系统.FastDFS 为互联网量身定制, 充分考虑了冗余备份.负载均衡.线性扩容等机制,并注重高可用.高性能等指标,使用 ...

  2. JS编程模式之初始化分支与惰性初始

    不同的浏览器对于相同或相似的方法可能有不同的实现.这时,您需要依据当前的浏览器的支持方法来选择对应的执行分支.这类分支有可能与很多,因此可能会减缓脚本的执行速度.但非要等到运行时才能分支吗?我们完全可 ...

  3. Flink学习笔记:异步I/O访问外部数据

    本文为<Flink大数据项目实战>学习笔记,想通过视频系统学习Flink这个最火爆的大数据计算框架的同学,推荐学习课程: Flink大数据项目实战:http://t.cn/EJtKhaz ...

  4. c语言数据结构学习心得——排序

    排序:将无序的序列重新排列为有序的序列. 插入类排序 插入类排序:在一个有序的序列中,插入一个新的关键字,知道所有的关键字都插入形成一个有序的序列. 直接插入排序:首先以一个元素为有序的序列,然后将后 ...

  5. Spark Programming Guide《翻译》

    转载必须注明出处:梁杰帆 在这里要先感谢原作者们!如果各位在这里发现了错误之处,请大家提出 1.Initializing Spark     Spark程序必须做的第一件事就是创建一个SparkCon ...

  6. python获取函数参数默认值的两种方法

    1.使用函数的__defaults__魔术方法 demo: # coding=utf-8 def f(a,b,c=1): pass f.__defaults__ 输出结果: (1,) 2.使用insp ...

  7. github提交项目

    1.建立git仓库 在GitHub上先新建一个仓库. 新建一个文件夹 cd git clone https://github.com/xxxxxxx/xxxxx.git 3.把你的项目拖进去,cd 进 ...

  8. python之文件读写(1)

    1. 从文件读取数据 关于对文件的操作,使用open(filename, mode),打开文件.与之对应的,close()用来关闭文件.对文件操作完毕切记要关闭. open函数参数: mode 参数有 ...

  9. ABP项目后台初始化数据库

    设置host为启动项,并修改连接字符串 在程序包管理控制台中,默认项目选中EFCore 执行Update-Database命令

  10. 洛谷 P1477 [NOI2008]假面舞会

    题目链接 题目描述 一年一度的假面舞会又开始了,栋栋也兴致勃勃的参加了今年的舞会. 今年的面具都是主办方特别定制的.每个参加舞会的人都可以在入场时选择一 个自己喜欢的面具.每个面具都有一个编号,主办方 ...