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

Input Specification:

Each input file contains one test case. Each case contains a positive integer N, followed by N lines of student information. Each line contains a student's namegenderID and grade, separated by a space, where name and ID are strings of no more than 10 characters with no space, gender is either F (female) or M (male), and grade is an integer between 0 and 100. It is guaranteed that all the grades are distinct.

Output Specification:

For each test case, output in 3 lines. The first line gives the name and ID of the female student with the highest grade, and the second line gives that of the male student with the lowest grade. The third line gives the difference grade​F​​−grade​M​​. If one such kind of student is missing, output Absent in the corresponding line, and output NA in the third line instead.

Sample Input 1:

3
Joe M Math990112 89
Mike M CS991301 100
Mary F EE990830 95

Sample Output 1:

Mary EE990830
Joe Math990112
6

Sample Input 2:

1
Jean M AA980920 60

Sample Output 2:

Absent
Jean AA980920
NA
#include <iostream>
using namespace std;
struct stu{
string name;
char gender;
string id;
int grade;
};
int main()
{
int N;cin>>N;
bool male=false,female=false;
stu tmp,maleLowest,femaleHighest;
while(N--){
cin>>tmp.name>>tmp.gender>>tmp.id>>tmp.grade;
if(tmp.gender=='M'){
/**性别为M*/
if(male==false){
male=!male;
maleLowest=tmp;
}else{
if(maleLowest.grade>tmp.grade){
maleLowest=tmp;
}
}
}else{
/**性别为F*/
if(female==false){
female=!female;
femaleHighest=tmp;
}else{
if(femaleHighest.grade<tmp.grade){
femaleHighest=tmp;
}
}
}
}
/**output*/
if(female==false) cout<<"Absent"<<endl;
else cout<<femaleHighest.name<<" "<<femaleHighest.id<<endl;
if(male==false) cout<<"Absent"<<endl;
else cout<<maleLowest.name<<" "<<maleLowest.id<<endl;
if(male==false||female==false) cout<<"NA"<<endl;
else cout<<(femaleHighest.grade-maleLowest.grade)<<endl;
system("pause");
return ;
}
												

PAT Advanced 1036 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分)

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

  3. PAT 1036 Boys vs Girls (25 分)

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

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

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

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

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

  6. PAT (Advanced Level) Practice 1036 Boys vs Girls (25 分)

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

  7. 【PAT甲级】1036 Boys vs Girls (25 分)

    题意: 输入一个正整数N(题干没指出范围,默认1e5可以AC),接下来输入N行数据,每行包括一名学生的姓名,性别,学号和分数.输出三行,分别为最高分女性学生的姓名和学号,最低分男性学生的姓名和学号,前 ...

  8. 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 ...

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

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

随机推荐

  1. java中 Excel表实现数据导入导出

    需要引入依赖: <!-- https://mvnrepository.com/artifact/org.apache.poi/poi --> <dependency> < ...

  2. 惠普DL360G6安装ESXi主机后设置多块网卡

    需要先把服务器的网线连接到路由器 然后打开esxi设置网络的netwoork adapters 选中多块网卡,点确定保持 然后在到esxi客户端操作: 直接下一步 这里填上路由器分配的网段ip即可了

  3. 一、基础篇--1.1Java基础-自定义注解的场景及实现

    自定义注解使用场景: 类属性自动赋值,例如对上下文.传入参数等赋值 验证对象属性完整性,例如,对参数的校验 代替配置文件功能,像spring基于注解的配置 可以生成文档,例如java 最早提供的注解. ...

  4. 使用type在对象方法中调用类方法

    type简介 type在Python中的作用是创建一个类. 我们创建类的时候一般会使用这样的方法: # -*- coding:utf-8 -*- class Student(object): coun ...

  5. python 调用c++类方法(1)

    myTest.cpp: #include<iostream> #include<vector> class MyTest { public: MyTest(); ~MyTest ...

  6. 使用discriminator实现鉴别器

    1在人员接口实现方法 public Employee getEmpByIdStep(Integer id); 2在映射文件进行配置 <!-- public Employee getEmpById ...

  7. 使用resultMap定义查询结果集,实现关联查询

    接下来介绍resultMap定义查询结果集,实现关联查询 1 首先在接口中定义操作的方法 public interface EmployeeMapperPlus { public Employee g ...

  8. 思科端口聚合的命令是channel-group

    锐捷设备的端口聚合命令是: int range f0/1-2 port-group 1 --------------------- == 思科设备的端口聚合 是: int range f0/1-2 c ...

  9. 【C++进阶:atoi()与itoa()】

    两种函数: atoi 把字符串转为整形: itoa 整形转为字符串: https://www.cnblogs.com/bluestorm/p/3168719.html

  10. 线对 Line pairs、LP(分辨率cy/mm)

    线对 (Line pairs) 是胶片.镜头等电影摄影领域的专用名词. 每毫米线对一般指分辨率的单位,指仪器在一毫米内能分辨出多少对线. 在一定尺度内的可分辨线对数常被用来衡量仪器的空间分辨能力,能分 ...