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. 移动Anaconda安装目录后导致图标变白以及Anaconda Navigator,Anaconda Prompt,jupyter notebook和spyder启动不了的解决方法

    Q:因为移动了Anaconda3的安装目录,所以Anaconda3的相应应用程序启动不了,包括图标也会变白 解决方法:修改对应快捷键的属性,有对应的启动位置,修改下位置路径配置以及图标(Anacond ...

  2. [论文理解] Squeeze-and-Excitation Networks

    Squeeze-and-Excitation Networks 简介 SENet提出了一种更好的特征表示结构,通过支路结构学习作用到input上更好的表示feature.结构上是使用一个支路去学习如何 ...

  3. 使用collection:分段查询结果集

    1.在人员接口书写方法 public List<Employee> getEmpsByDeptId(Integer deptId); 2在人员映射文件中进行配置 <!-- publi ...

  4. java hashset输出

    for (Map.Entry<String, String> me : id_label_map.entrySet()) { System.out.println(me.getKey() ...

  5. JQuery插件 aos.js

    简介: aos.js是一款效果超赞的页面滚动元素动画jQuery动画库插件.该动画库可以在页面滚动时提供28种不同的元素动画效果,以及多种easing效果.在页面往回滚动时,元素会恢复到原来的状态. ...

  6. nginx重要特性

    反向代理负载均衡实现高并发 1.反向代理反向代理(Reverse Proxy)方式是指以代理服务器来接受Internet上的连接请求,然后将请求转发给内部网络上的服务器:并将从服务器上得到的结果返回给 ...

  7. 旅游局nginx配置

    #user nobody;worker_processes 1; #error_log logs/error.log;#error_log logs/error.log notice;#error_l ...

  8. iOS客户端使用教程

    使用须知 支持 ios9.0 以上系统,兼容 iphone.ipad.ipod 等设备. 电脑上用 PP 助手安装 Shadowrocket   Mac电脑上用PP助手安装Shadowrocket 下 ...

  9. 深入理解java:2.2. 同步锁Synchronized及其实现原理

    同步的基本思想 为了保证共享数据在同一时刻只被一个线程使用,我们有一种很简单的实现思想,就是 在共享数据里保存一个锁 ,当没有线程访问时,锁是空的. 当有第一个线程访问时,就 在锁里保存这个线程的标识 ...

  10. ELK7.4.0分析nginx json日志

    ELK7.4.0单节点部署 环境准备 安装系统,数据盘设置为/srv 内核优化参考 我们需要创建elk专用的账号,并创建所需要的目录并授权 useradd elk; mkdir /srv/{app,d ...