PAT 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 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 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
#include<bits/stdc++.h>
using namespace std;
typedef long long ll; int main(){
int t;
cin >> t;
int mannum = ;
string manname = "man";
string manid = "";
int fenum = -;
string fename = "feman";
string feid = "";
while(t--){
string s1,s2,s3;
int grade;
cin >> s1 >> s2 >> s3 >> grade;
if(s2 == "M"){
if(grade < mannum){
manname = s1;
manid = s3;
mannum = grade;
}
}
else{
if(grade > fenum){
fename = s1;
feid = s3;
fenum = grade;
}
}
}
if(fename != "feman"){
cout << fename << " " << feid << endl;
}
else cout << "Absent" << endl;
if(manname != "man"){
cout << manname << " " << manid << endl;
}
else cout << "Absent" << endl; if(fename != "feman"&&manname != "man"){
cout << fenum - mannum;
}
else cout << "NA"; return ;
}
ez
PAT 1036 Boys vs Girls (25 分)的更多相关文章
- 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分)
PAT甲级:1036 Boys vs Girls (25分) 题干 This time you are asked to tell the difference between the lowest ...
- PAT 甲级 1036 Boys vs Girls (25 分)(简单题)
1036 Boys vs Girls (25 分) This time you are asked to tell the difference between the lowest grade ...
- 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甲级】1036 Boys vs Girls (25 分)
题意: 输入一个正整数N(题干没指出范围,默认1e5可以AC),接下来输入N行数据,每行包括一名学生的姓名,性别,学号和分数.输出三行,分别为最高分女性学生的姓名和学号,最低分男性学生的姓名和学号,前 ...
- PAT Advanced 1036 Boys vs Girls (25 分)
This time you are asked to tell the difference between the lowest grade of all the male students and ...
- PAT (Advanced Level) Practice 1036 Boys vs Girls (25 分)
This time you are asked to tell the difference between the lowest grade of all the male students and ...
- PAT 1036 Boys vs Girls[简单]
1036 Boys vs Girls (25 分) This time you are asked to tell the difference between the lowest grade of ...
- PAT甲题题解-1036. Boys vs Girls (25)-找最大最小,大水题
题意:给出n个人的姓名.性别.ID.分数,让你找出其中哪个妹纸分数最高.哪个汉子分数最低.以及他们的差如果没有妹纸或者汉子,则对应输出Absent,差用NA代替. 就是for一遍找最大最小值,水题 # ...
随机推荐
- selenium问题之定位不到元素(NoSuchElementException)
在使用selenium+爬虫的时候,经常会遇到一个问题,就是NoSuchElementException,定位不到元素的问题 一,打开了新页面,一般selenium点击新链接跳转打开了一个新页面,那么 ...
- ruby+selenium-webdriver一步一步完成自动化测试-----准备篇
这一系列文章目的不是讲ruby,也不是讲selenium-webdriver,而是通过一个登录soso首页的小例子讲怎样一步一步写好自动化测试.目标是:面向对象编程,实现逻辑与数据分离. 如果你觉得已 ...
- LeetCode:旋转数组
最近看了一道题,自己做个过后又参考了网上的解法,为了加深对这个解法的理解和记忆于是有了这篇博客,供自己以后复习用 题目: 给定一个数组,将数组中的元素向右移动 k 个位置,其中 k 是非负数. 示例 ...
- PAT 2019-3 7-3 Telefraud Detection
Description: Telefraud(电信诈骗) remains a common and persistent problem in our society. In some cases, ...
- Egyptian Collegiate Programming Contest 2017 (ACM ECPC 2017) - original tests edition
题目链接:https://codeforces.com/gym/101856 D. Dream Team 题意:n个点,让你连边成为一棵树,边权为顶点的GCD(u,v).求所有边权和的最大值. 思路: ...
- 更新python的依赖包,亲测!
输入pip install --upgrade pandas 无需卸载,让它自己更新就好 pandas可以改成别的包
- Percona XtraDB Cluster集群5.7 开启SSL认证
mysqldump -uroot -p --ssl-cert=/data/mysql/client-cert.pem --ssl-key=/data/mysql/client-key.pem -h 1 ...
- Deepin环境下安装科学研究版Python和Pytorch--防网卡
Deepin环境下安装科学研究版Python和Pytorch--防网卡 由于本教程所引起的一切损失作者概不负责,本教程不使用pip和conda命令,因此下载好包后配合U盘可以给某个机器进行离线安装 · ...
- C++中初始化列表的使用
1,初始化列表是在 C++ 中才引入的: 2,以“类中是否可以定义 const 成员?”这个问题来引入初始化列表: 1,const 这个关键字可以定义真正意义上的常量,也可以在某些情况下定义只读变量: ...
- make源文件时出现 /usr/bin/ld: cannot find -lstdc++ 错误
解决CentOS 7 中,make源文件时出现 /usr/bin/ld: cannot find -lstdc++ 错误 在CentOS 7中,使用static方法编译,需要安装static vers ...