PAT 1036 Boys vs Girls[简单]
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 name, gender, ID 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 gradeF−gradeM. 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[简单]的更多相关文章
- PAT 1036 Boys vs Girls (25 分)
1036 Boys vs Girls (25 分) This time you are asked to tell the difference between the lowest grade ...
- PAT 1036 Boys vs Girls
#include <cstdio> #include <iostream> #include <cstdlib> #include <algorithm> ...
- PAT 1036 Boys vs Girls (25分) 比大小而已
题目 This time you are asked to tell the difference between the lowest grade of all the male students ...
- PAT 甲级 1036 Boys vs Girls (25 分)(简单题)
1036 Boys vs Girls (25 分) This time you are asked to tell the difference between the lowest grade ...
- PAT甲级:1036 Boys vs Girls (25分)
PAT甲级:1036 Boys vs Girls (25分) 题干 This time you are asked to tell the difference between the lowest ...
- 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 ...
- 1036 Boys vs Girls (25 分)
1036 Boys vs Girls (25 分) This time you are asked to tell the difference between the lowest grade of ...
- 1036 Boys vs Girls (25分)(水)
1036 Boys vs Girls (25分) This time you are asked to tell the difference between the lowest grade o ...
- PAT (Advanced Level) 1036. Boys vs Girls (25)
简单题. #include<iostream> #include<cstring> #include<cmath> #include<algorithm> ...
随机推荐
- 【BZOJ】1093: [ZJOI2007]最大半连通子图(tarjan+拓扑序)
http://www.lydsy.com/JudgeOnline/problem.php?id=1093 两个条件综合起来加上求最大的节点数,那么很明显如果是环一定要缩点. 然后再仔细思考下就是求da ...
- 纪念伟大的sb错-noip滚粗
人弱就是弱,被sb错虐翻. 手一抖一生就毁了 开此博文纪念这个伟大的sb错! noip2014 d2t2逆bfs后删点手残没考虑后效性,完美爆80 愿省选rp++,求进noi,orz
- 关于CSS 里的_width是什么意思???
下划线_IE6支持下划线,IE7和firefox等均不支持下划线. 你那个代码的意思就是IE6下面宽度 449px;其他浏览器下宽度 460px; 友情提醒:这种HACK写法,得把_width写在正常 ...
- QQ在线聊天代码获取和使用教程
在网站上挂上悬浮QQ是一种有效的推广方式,QQ正常情况下是不被允许临时会话的,需要加为好友才可以,这样很不友好, 当今每个行业都是有很多人在做,竞争很激烈,对客户的友好是增加订单的有效途径. 地址:h ...
- C++关键字之friend
原则上, 类的私有(private)和受保护(protected)成员不能从声明它们的同一类外部访问.但是, 此规则不适用于友元 "friends". 以friend关键字修饰的函 ...
- python3----练习题(爬取电影天堂资源,大学排名,淘宝商品比价)
import requests import re url = 'http://www.ygdy8.net/html/gndy/dyzz/list_23_{}.html' for n in range ...
- 自己动手写CPU之第九阶段(2)——载入存储指令说明2(lwl、lwr)
将陆续上传新书<自己动手写CPU>.今天是第38篇,我尽量每周四篇,可是近期已经非常久没有实现这个目标了.一直都有事,不好意思哈. 开展晒书评送书活动,在q=%E4%BA%9A%E9%A9 ...
- 让iOS应用支持不同版本的系统与设备
本文转载至 http://blog.csdn.net/pucker/article/details/11980811 最近一直在做app的iOS 6和7的同时适配工作,所以在此介绍一下系统与设备的兼 ...
- SQL 语句快速参考
来自 W3CSchool 的 SQL 快速参考 SQL 语句 语法 AND / OR SELECT column_name(s)FROM table_nameWHERE conditionAND|OR ...
- SQL Server中的SQL语句优化与效率
很多人不知道SQL语句在SQL SERVER中是如何执行的,他们担心自己所写的SQL语句会被SQL SERVER误解.比如: select * from table1 where name='zhan ...