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

PAT 1036

2019-11-08 03:02:36
字体:
来源:转载
供稿:网友
#include<cstdio>#include<algorithm>#include<stdlib.h>struct pNode{	char name[15];	char gender;	char id[15];	int grade;}temp,ans1,ans2;//ans1为女生最高年级,ans2为男生最低年级bool great(pNode node1,pNode node2){	return node1.grade>=node2.grade;}int main(){	int n,diff;	scanf("%d",&n);	ans1.grade=-1;	ans2.grade=101;	for(int i=0;i<n;i++)	{		scanf("%s%s%s%d",&temp.name,&temp.gender,&temp.id,&temp.grade);		if(temp.gender=='F'&&great(temp,ans1)==true)	ans1=temp;		if(temp.gender=='M'&&great(temp,ans2)==false) 	ans2=temp;		}	diff=ans1.grade-ans2.grade;	if(ans1.grade!=-1)		PRintf("%s %s/n",ans1.name,ans1.id);	else printf("Absent/n");	if(ans2.grade!=101)		printf("%s %s/n",ans2.name,ans2.id);	else printf("Absent/n");	if(ans1.grade!=-1&&ans2.grade!=101)		printf("%d/n",diff);	else printf("NA");	system("pause");	return 0;}
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表