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 ;
}

最新文章

  1. 感悟 GNU C 以及将 Vim 打造成 C/C++ 的半自动化 IDE
  2. selenium自动化基础知识
  3. python(24)urlencode和urldecode
  4. 要杀死一切APP,微信应用号是不是被神化了?
  5. l中断的实现
  6. 百度 UEditor 简单安装调试和调用,网上其它的教程太官方了,不适合新手
  7. 关于Linux vi命令 vi命令一览表
  8. hbase总结:如何监控region的性能
  9. Haskell函数的语法
  10. C/C++中的const int*和int * const
  11. 实现了在android实现左右滑动切换界面的效果
  12. Google Protocol Buffers和java字符串处理控制
  13. 给“file”类型的input框赋值的问题
  14. PHP项目开发
  15. Python使用import导入相对路径的其他py文件
  16. input按钮去掉默认样式
  17. 【UML】Java代码与UML模型相互转换方法
  18. Spring Boot重要内容
  19. Docker Builders:Builder pattern vs. Multi-stage builds in Docker
  20. MySQL的查询语句

热门文章

  1. php面试笔记(3)-php基础知识-运算符
  2. rabbit MQ 消息队列
  3. Webpack实战(八):教你搞懂webpack如果实现代码分片(code splitting)
  4. a标签没有闭合引起自动插入很多a标签的问题
  5. RabbitMQ配置死信队列
  6. 微信小程序组件构建UI界面小练手 —— 表单登录注册微信小程序
  7. C++中字符常量与字符常量不能直接相加
  8. Visual Studio Code中C/C++的环境配置
  9. Umi 小白纪实(三)—— 震惊!路由竟然如此强大!
  10. Zabbix3.4使用详解