首页 > 学院 > 开发设计 > 正文

1036. Boys vs Girls (25)

2019-11-14 09:28:15
字体:
来源:转载
供稿:网友
#include<iostream>#include<algorithm>#include<vector>#include<map> #include<string>#include<set>using namespace std;struct rec{	string name;//	char gender;	string id;	int grade; }; vector<rec> boy, girl;bool comp(rec a, rec b){	if(a.grade < b.grade) return true;	else return false;}int main(){	int n;	cin>>n;	for(int i = 0; i < n; i++){		rec a;		char gender;		cin>>a.name>>gender>>a.id>>a.grade;		if(gender == 'M'){			boy.push_back(a);		}		else{			girl.push_back(a);		}	}	sort(boy.begin(),boy.end(),comp);	sort(girl.begin(),girl.end(),comp);	int nboy = boy.size();	int ngirl = girl.size();	bool abse = false;	if(ngirl == 0){		PRintf("Absent/n");		abse = true;	}	else{		cout<<girl[ngirl - 1].name<<" "<<girl[ngirl - 1].id<<endl;	}	if(nboy == 0){		printf("Absent/n");		abse = true;	}	else{		cout<<boy[0].name<<" "<<boy[0].id<<endl;	}	if(abse == true){		printf("NA");	}	else{		cout<<girl[ngirl - 1].grade - boy[0].grade;	}	return 0;}
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表