您的位置:首页 > 其它

【PAT】1036. Boys vs Girls

2017-01-17 16:33 134 查看
#include <iostream>
#include <cstdio>

#include <cstring>
using namespace std;

struct person{
char id[15];
char name[15];
int grade;
char sex;
}high,low,temp;

void init(){
high.grade=-1;
low.grade=101;
}
int main()
{
int n;
cin>>n;
int flagM=0,flagF=0;
init();
while(n--){
scanf("%s %c %s %d",temp.name,&temp.sex,temp.id,&temp.grade);
if(temp.sex=='F' && temp.grade>high.grade){ high=temp;flagF=1;}
if(temp.sex=='M' && temp.grade<low.grade){ low=temp;flagM=1;}
}
if(flagF) printf("%s %s\n",high.name,high.id);
else cout<<"Absent"<<endl;
if(flagM) printf("%s %s\n",low.name,low.id);
else cout<<"Absent"<<endl;
if(flagF && flagM) cout<<high.grade-low.grade<<endl;
else cout<<"NA"<<endl;
return 0;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: