PAT1036. Boys vs Girls (25)
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
struct Student{
string name;
string gender;
string id;
int grade;
int idd;
};
int n;
bool cmp(Student a,Student b){
return a.grade<b.grade;
}
vector<Student> studentSet;
int main(){
cin>>n;
for(int i=0;i<n;i++){
Student s;
cin>>s.name>>s.gender;
cin>>s.id>>s.grade;
s.idd=i;
studentSet.push_back(s);
}
sort(studentSet.begin(),studentSet.end(),cmp);
int p=-1,q=-1;
for(int i=0;i<n;i++){
if(studentSet[i].gender[0]=='M'){
if(p==-1){p=i;}
}
if(studentSet[i].gender[0]=='F'){
q=i;
}
}
int flag=-1;
if(q==-1){
cout<<"Absent"<<endl;
flag=1;
}else{
cout<<studentSet[q].name<<" "<<studentSet[q].id<<endl;
}
if(p==-1){
cout<<"Absent"<<endl;
flag=1;
}else{
cout<<studentSet[p].name<<" "<<studentSet[p].id<<endl;
}
if(flag==-1){
cout<<(studentSet[q].grade-studentSet[p].grade)<<endl;
}else{
cout<<"NA"<<endl;
}
return 0;
}
PAT1036. Boys vs Girls (25)的更多相关文章
- PAT1036:Boys vs Girls
1036. Boys vs Girls (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue This ti ...
- 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 分)
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分)
PAT甲级:1036 Boys vs Girls (25分) 题干 This time you are asked to tell the difference between the lowest ...
- PAT 1036 Boys vs Girls (25分) 比大小而已
题目 This time you are asked to tell the difference between the lowest grade of all the male students ...
- 1036. Boys vs Girls (25)
#include <stdio.h>#include <string.h>int main(){ int n,i; while(scanf("%d",&am ...
- PAT甲题题解-1036. Boys vs Girls (25)-找最大最小,大水题
题意:给出n个人的姓名.性别.ID.分数,让你找出其中哪个妹纸分数最高.哪个汉子分数最低.以及他们的差如果没有妹纸或者汉子,则对应输出Absent,差用NA代替. 就是for一遍找最大最小值,水题 # ...
- 1036 Boys vs Girls (25)(25 point(s))
problem This time you are asked to tell the difference between the lowest grade of all the male stud ...
随机推荐
- 【BZOJ3673/3674】可持久化并查集/可持久化并查集加强版 可持久化线段树
[BZOJ3674]可持久化并查集加强版 Description Description:自从zkysb出了可持久化并查集后……hzwer:乱写能AC,暴力踩标程KuribohG:我不路径压缩就过了! ...
- oracle用于判断时间条件为当天的写法(当前日期加一天)
trunc(sysdate + 1, 'dd')为当前日期加一天: 来自: and wf.start_time between sysdate and trunc(sysdate + 1, 'dd') ...
- python3 简单爬虫
爬取虎牙直播分类页面的主播的头像,名字,人气 今天学习了python3爬虫,上课闲着无聊,自己写了一个爬虫 就顺着老师思路 爬了虎牙直播分类页面的主播,头像,名字,和人气 HuYaCateScrapy ...
- Ionic的下拉框在手机上点击无效
最近在维护ionic+angular的项目,在浏览器使用下拉框的时候调试的时候,一切正常. 但是在手机上测试的时候,遇到这个问题. 我使用的版本是ionic1.3.1,不知道新版本有没有解决这个bug ...
- 利用jdt快速实现pmd的功能
jdt可以做语法树分析,并且支持visitor模式对代码进行分析.跟pmd的分析方式一样,我们只要实现 visitor接口即可实现一个插件. @Service("requestMapping ...
- python多线程的适用场景
1.多线程对于计算密集型无用 需求:列表li1每个元素加1,列表li2每个元素加100 # 导入模块 import threading li1 = [11, 22, 33] # +1 li2 = [4 ...
- 运行hadoop自带的wordcount例子程序
1.准备文件 [root@master ~]# cat input.txt hello java hello python hello c hello java hello js hello html ...
- (3.8)常用知识-临时表、表变量、CTE的对比
转自:https://www.cnblogs.com/xiaozhi1236/p/5895935.html 深入了解:https://www.cnblogs.com/kissdodog/archive ...
- HDU1838:Chessboard(线性dp)
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1838 这题也挺不错的.首先题目说了,棋盘的右下角一定是'1',另外棋盘里面至少包含一个1,所以最小值是1, ...
- [设计模式]State模式
<Java与模式> 又称状态对象模式.状态模式是对象的行为模式.GOF95 一个对象的行为取决于一个或者多个动态变化的属性,这样的属性叫做状态.这样的对象叫做有状态的对象(stateful ...