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>
#include <string>
#include <cstring>
#include <algorithm>
using namespace std;
struct node
{
string name;
char sex;
string id;
int score;
}a[];
int main()
{
int n;
while(cin>>n){
int num_M=,num_F=;
int index_M=,index_F=;
int min_M=,max_F=;
for(int i=;i<n;i++){
cin>>a[i].name>>a[i].sex>>a[i].id>>a[i].score;
if(a[i].sex=='M'){
num_M++;
if(a[i].score<min_M){
index_M=i;
min_M=a[i].score;
}
}else if(a[i].sex=='F'){
num_F++;
if(a[i].score>max_F){
index_F=i;
max_F=a[i].score;
}
} }
if(num_F==){
cout<<"Absent"<<endl;
}else{
cout<<a[index_F].name<<" "<<a[index_F].id<<endl;
}
if(num_M==){
cout<<"Absent"<<endl;
}else{
cout<<a[index_M].name<<" "<<a[index_M].id<<endl;
}
if(num_M==||num_F==){
cout<<"NA"<<endl;
}else{
cout<<a[index_F].score-a[index_M].score<<endl;
}
}
return ;
}

PAT (Advanced Level) Practice 1036 Boys vs Girls (25 分)的更多相关文章

  1. PAT (Advanced Level) Practice 1027 Colors in Mars (20 分) 凌宸1642

    PAT (Advanced Level) Practice 1027 Colors in Mars (20 分) 凌宸1642 题目描述: People in Mars represent the c ...

  2. PAT (Advanced Level) Practice 1019 General Palindromic Number (20 分) 凌宸1642

    PAT (Advanced Level) Practice 1019 General Palindromic Number (20 分) 凌宸1642 题目描述: A number that will ...

  3. PAT (Advanced Level) Practice 1011 World Cup Betting (20 分) 凌宸1642

    PAT (Advanced Level) Practice 1011 World Cup Betting (20 分) 凌宸1642 题目描述: With the 2010 FIFA World Cu ...

  4. PAT (Advanced Level) Practice 1005 Spell It Right (20 分) 凌宸1642

    PAT (Advanced Level) Practice 1005 Spell It Right (20 分) 凌宸1642 题目描述: Given a non-negative integer N ...

  5. PAT (Advanced Level) Practice 1001 A+B Format (20 分) 凌宸1642

    PAT (Advanced Level) Practice 1001 A+B Format (20 分) 凌宸1642 题目描述: Calculate a+b and output the sum i ...

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

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

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

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

  8. PAT 1036 Boys vs Girls (25 分)

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

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

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

随机推荐

  1. step1:准备歌词之《前端开发是个啥》

    以下是给大家介绍前端开发的填词,曲子是李圣杰的<最近>,大家喜欢可以试试唱. 点赞关注超过100的平台,我后续上来发本人原唱视频(目前正在练习中...),另外大家觉得哪些词写得不好的,欢迎 ...

  2. SSM/SSH框架的MySQL 读写分离实现的一种简单方法

    简介 MySQL已经是使用最为广泛的一种数据库,往往实际使用过程中,为实现高可用及高性能,项目会采用主丛复制的方式实现读写分离.MySQL本身支持复制,通过简单的配置即可实现一主多从的配置,具体实现可 ...

  3. 1058 - Parallelogram Counting 计算几何

    1058 - Parallelogram Counting There are n distinct points in the plane, given by their integer coord ...

  4. 大数相乘----C语言

    /* 大数相乘: 因为是大数,乘积肯定超出了能定义的范围,因此考虑用数组存储,定义三个数组,分别存储乘数,被乘数和积. 规则与平常手算一样,从个位开始分别与被乘数的每一位相乘,但是有一点不同的是:我们 ...

  5. React之this绑定

    一.首先看一下没有绑定this的情况 class App extends React.Component{ constructor(props){ super(props) console.log(' ...

  6. Django 系列

    Django基础 Django框架简介 Django 静态文件 Django request对象与ORM简介 Django路由系统 Django之视图层 Django之模板层 Django的setti ...

  7. Centos7之firewall配置命令

    firewalld的基本使用 查看状态:systemctl status firewalld 启动:systemctl start firewalld 停止:systemctl stop firewa ...

  8. 二、GLTF模型支持

    1.安装ColladaToGltf.exe 2. @echo off cd C:\Users\wangc04\Desktop\daeconverting\ColladaToGltfcollada2gl ...

  9. js中(function(){})()的写法用处

    直到今天我才明白的一个玩意!!! 来来来,首先嘛,JS中函数有两种命名方式 1.一种是声明式. 而声明式会导致函数提升,function会被解释器优先编译.即我们用声明式写函数,可以在任何区域声明,不 ...

  10. LAN、WAN和WLAN的区别

    1.LAN 局域网(Local Area Network)接口,通俗讲就是路由和用户之间网线口: 2.WAN 广域网(Wide Area Network),通俗讲就是和猫外部网连接的网线口: 3.WL ...