1036 Boys vs Girls (25 分)

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 nameand 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

题目大意:给出m个女孩和男孩的名字课程分数信息,求女孩中分数最高与男孩中分数最低的。

//这道题真的老简单了。。。一次过。。都不想写博客来着。。

#include <iostream>
#include <algorithm>
#include <vector>
#include<cstdio>
using namespace std; int main()
{
int n;
cin>>n;
string name,s,task;
int sco;
string fn,mn;//最终的名字
string ft,mt;//最终的科目
int fs=-,ms=;//最终的得分。
for(int i=;i<n;i++){
cin>>name>>s>>task>>sco;
if(s=="F"&&sco>fs){
fn=name;
ft=task;
fs=sco;
}else if(s=="M"&&sco<ms){
mn=name;
mt=task;
ms=sco;
}
}
if(fs==-){//如果没有女性
cout<<"Absent\n";
}else {
cout<<fn<<" "<<ft<<"\n";
}
if(ms==){
cout<<"Absent\n";
}else{
cout<<mn<<" "<<mt<<"\n";
}
if(fs==-||ms==){
cout<<"NA";
}else{
cout<<fs-ms;
} return ;
}

最新文章

  1. linux 2.6 驱动笔记(二)
  2. VisualSVN-Server 安装以及使用教程
  3. Python语言精要---上
  4. python 进程信息
  5. [译]36 Days of Web Testing(五)
  6. Spring dbcp连接池简单配置 示例
  7. 搭建solr单机版
  8. 51驱动LCD1602
  9. interface接口
  10. 关于一些常用的linux命令
  11. J2EE进阶(七)利用SSH框架根据数据表建立model类
  12. SQL 查找存在某内容的存储过程都有哪些
  13. vue 自定义过滤器 格式化金额(保留两位小数)
  14. CSS Transform Style
  15. sql开启远程访问
  16. BZOJ1307: 玩具 单调队列
  17. Linux 替换^M字符 方法
  18. Wannafly挑战赛20-A,B
  19. Subsonic 介绍
  20. ECharts概念学习系列之ECharts官网教程之在 webpack 中使用 ECharts(图文详解)

热门文章

  1. 阿里云ecs开启x11图形化桌面
  2. AD smart pdf 中文丢失
  3. scanner, BufferedReader, InputStreamReader 区别及特殊字符的输入
  4. 【BZOJ】1030: [JSOI2007]文本生成器(递推+ac自动机)
  5. JAVA基础之訪问控制权限(封装)
  6. &quot;reason&quot;:&quot;No handler for type [attachment] declared on field [file]&quot; 最完全解决方案
  7. MathType二次偏导怎么表示
  8. U盘插入拔出提示
  9. 【BZOJ3781、2038】莫队算法2水题
  10. 160608、mysql距离函数st_distance