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> ...
随机推荐
- 人脸验证算法Joint Bayesian详解及实现(Matlab)
python http://blog.csdn.net/cyh_24/article/details/49059475 github https://github.com/johnnyconstant ...
- Spring Framework 官方文档学习(四)之Validation、Data Binding、Type Conversion
本篇太乱,请移步: Spring Framework 官方文档学习(四)之Validation.Data Binding.Type Conversion(一) 写了删删了写,反复几次,对自己的描述很不 ...
- 第二百七十节,Tornado框架-生成验证码图片,以及验证码结合Session验证
Tornado框架-生成验证码图片,以及验证码结合Session验证 第一.生成验证码图片 生成验证码图片需要两个必须模块 1.python自带的random(随机模块) 2.Pillow()图像处 ...
- serv-u ftp服务器搭建
以前在学校的时候,学校的整个宿舍楼都是在一个局域网中,经常有人用个人电脑搭个网站或者FTP啊什么的,主要是进行一些影视资源的传播活动.不乏有些资源充沛的有志青年利用业余时间翻译某岛国影视资源,利用局域 ...
- 《敏捷软件开发-原则、方法与实践》-Robert C. Martin读书笔记(转)
Review of Agile Software Development: Principles, Patterns, and Practices 本书主要包含4部分内容,这些内容对于今天的软件工程师 ...
- hdu 3008:Warcraft(动态规划 背包)
Warcraft Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Su ...
- Socket长连接和短连接的区别
https://blog.csdn.net/jasonjwl/article/details/52085264 短连接 连接->传输数据->关闭连接 HTTP是无状态的,浏览器和服务器每进 ...
- 面试题思考:web中关于一些容器基本概念的简单总结
关键字:应用服务器.web服务器.web容器.jsp容器.servlet容器. 1.应用服务器: 作为应用程序服务器,要求可以通过各种协议(包括 HTTP 协议)把商业逻辑暴露给(expose)客户端 ...
- jqgrid自动换行
JQGrid表头自动换行的办法: 如果table的header部分字段太多或字段文字太长需要自动换行时,可尝试如下css. <style type="text/css" me ...
- 模拟http请求 带 chunked解析办法二
以PHP代码为例 //这个是解析chuned块 get_chunk_data($fsock) { $data = ''; while(true) { $len = hexdec(fgets($fsoc ...