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

PAT 1036 Boys vs Girls[简单]的更多相关文章

  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

    #include <cstdio> #include <iostream> #include <cstdlib> #include <algorithm> ...

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

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

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

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

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

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

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

  7. 1036 Boys vs Girls (25 分)

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

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

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

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

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

随机推荐

  1. js学习笔记24----焦点事件

    事件: onfous : 元素获取焦点时触发事件 onblur : 元素失去焦点时触发事件 方法: obj.focus(); 可指定元素设置焦点 obj.blur(); 取消指定元素的焦点 obj.s ...

  2. Reveal Jquery 模式对话框插件

    /* * jQuery Reveal Plugin 1.0 * www.ZURB.com * Copyright 2010, ZURB * Free to use under the MIT lice ...

  3. 用javascript技术读取注册表中软件安装位置并启动本地软件

    1.首先读取注册表中本地软件安装的位置,如果未安装则无就跳转到下载页面. 2.启动软件,关闭页面. 3.如报错提示. <SCRIPT language=javascript>  <! ...

  4. 关于VS2013的安装遇到的问题

    老师突然说实验一需要用代码实现,我之前配置的cocos的编程环境是cocos+VS2013,是很稳定的 但是,我安装unity5.5的时候,不小心选择了顺带安装了VS2015,就等于我电脑里面有了两个 ...

  5. 004杰信-关于formSubmit('factorycreate.action','_self')路径的疑惑

    本文材料来源于传智播客,在此说明. 整个项目结构:

  6. STL的map容器将第3个模板参数设为less_equal或greater_equal会怎样?

    最近都在学Linux系统编程,用C就足矣,有段时间没碰C++了,于是实现些算法练手. 实现多项式乘法的时候发现有几项没有合并同类项,最终调试到这一步时发现了问题. res是map类型,用find查找k ...

  7. 在J2EE的Web应用中,编译后的class文件存放的目录为(选择1项)

    在J2EE的Web应用中,编译后的class文件存放的目录为(选择1项) A. classes目录 B. images目录 C. jar目录 D. 任意位置 解答:A

  8. 【Debian】ftp安装

    http://www.2cto.com/os/201107/98311.html http://jingyan.baidu.com/article/adc815133476bdf723bf7393.h ...

  9. 怎么用MathType解决Word公式排版很乱的问题

    现在办公室起草文件,期刊论文投稿.学校试着编辑都要先在Word中编辑好后再打印出来.在Word中编辑这些文本内容时,如果遇到公式就要使用专门的MathType公式编辑器.而有很多人在用MathType ...

  10. Powershell理解汇总

    官方帮助文档https://msdn.microsoft.com/zh-cn/powershell/scripting/powershell-scripting 管道/重定向 管道 :  是指把上一条 ...