AC代码

#include <cstdio>
#include <algorithm> using namespace std; const int max_n = 11000; struct Stu {
char name[20];
char gender;
char id[20];
char grade;
} boys_l, girls_h, temp; void init() { //初始化,男生女生的成绩
//不能设置为100和0, 考虑边界值
boys_l.grade = 101;
girls_h.grade = -1;
} int main() {
init();
#ifdef ONLINE_JUDGE
#else
freopen("1.txt", "r", stdin);
#endif // ONLINE_JUDGE}
int n, girls_num = 0, boys_num = 0;
scanf("%d", &n);
for(int i = 0; i < n; i++) {
scanf("%s %c %s %d", temp.name, &temp.gender, temp.id, &temp.grade);
//printf("%s %c %s %d\n", temp.name, temp.gender, temp.id, temp.grade);
if(temp.gender == 'F') { //找出女生中成绩最高的且计算人数
girls_num++;
if(temp.grade > girls_h.grade) girls_h = temp;
}
if(temp.gender == 'M') {
boys_num++;
if(temp.grade < boys_l.grade) boys_l = temp;
}
}
/* printf("%s %s %d\n", girls_h.name, girls_h.id, girls_h.grade);
printf("%s %s %d\n", boys_l.name, boys_l.id, boys_l.grade);
printf("%d", girls_h.grade - boys_l.grade);
*/
if(boys_num&&girls_num) {
printf("%s %s\n", girls_h.name, girls_h.id);
printf("%s %s\n", boys_l.name, boys_l.id);
printf("%d", girls_h.grade - boys_l.grade);
} else if(boys_num == 0 && girls_num != 0) {
printf("%s %s\n", girls_h.name, girls_h.id);
printf("Absent\n");
printf("NA");
} else if(girls_num == 0 && boys_num != 0) {
printf("Absent\n");
printf("%s %s\n", boys_l.name, boys_l.id);
printf("NA");
} else {
printf("Absent\n");
printf("Absent\n");
printf("NA");
}
return 0;
}

PAT A1036 Boys vs Girls(25)的更多相关文章

  1. PAT 1036 Boys vs Girls (25 分)

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

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

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

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

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

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

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

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

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

  6. PAT 1036 Boys vs Girls[简单]

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

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

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

  8. PAT (Advanced Level) 1036. Boys vs Girls (25)

    简单题. #include<iostream> #include<cstring> #include<cmath> #include<algorithm> ...

  9. PAT Advanced 1036 Boys vs Girls (25 分)

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

随机推荐

  1. Mybatis源码学习之反射工具(三)

    简述 MyBatis在进行参数处理.结果映射等操作时,会涉及大量的反射操作.Java中的反射虽然功能强大,但是代码编写起来比较复杂且容易出错,为了简化反射操作的相关代码,MyBatis提供了专门的反射 ...

  2. ORACLE表名与列名小写转成大写

    批量将表名变为大写 begin for c in (select table_name tn from user_tables where table_name <> upper(tabl ...

  3. csp-s模拟84

    T1: 考虑如何能按顺序生成光滑数.对每个质数用队列维护包含此质数的候选集合,每次从所有队首取出最小的作为一个光滑数,用每个质数乘上这个光滑数并加入相应候选集合.这样不会漏掉一个光滑数,但会有重复.比 ...

  4. DDCTF-2018-writeup(5misc)

    打了好几天最后也只是80多名,我好菜啊.jpg 0x00  (╯°□°)╯︵ ┻━┻ 题目: (╯°□°)╯︵ ┻━┻ d4e8e1f4a0f7e1f3a0e6e1f3f4a1a0d4e8e5a0e6 ...

  5. Nginx数据结构之内存池

    基本结构 1. ngx_pool_t struct ngx_pool_s { ngx_pool_data_t d; size_t max; ngx_pool_t *current; ngx_chain ...

  6. Google 插件的使用

    每次看英文网页或者文档的时候总会碰到不认识单词,就想能不能选中单词就可以显示翻译?于是就安装Google浏览器的翻译插件,总的来说,蛮繁琐的. 1.先安装谷歌访问助手 (1.)直接百度谷歌访问助手 ( ...

  7. centos7 下安装和配置 mongodb (重点)

    1.下载安装包 wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-4.0.4.tgz 2.解压 tar -zxvf m ...

  8. maven项目无法导入Oracle的jdbc连接jar包【我】

    导入一个maven项目,启动一直报错 找不到Oracle的jdbc连接驱动Class, 用Eclipse导入 ojdbc14.jar 连接包,各种方法都无效,无法引入到部署后的lib目录中,可以直接放 ...

  9. Linux CentOS汉化系统

    u root切换为root用户 写入环境变量 echo "export LANG="zh_CN.UTF8"">>/etc/profile sourc ...

  10. React Native常用的第三方开源库

    记录一下自己暂目前了解和使用的一些开源库和官方文档和优秀博客介绍,希望对你有帮助☺️: 1.Toast: https://github.com/magicismight/react-native-ro ...