A1036 Boys vs Girls


#include<stdio.h>
//#define LOCAL
 //还是需要结构体啊
//后来发现其实char gender是不需要的
 //char[2] gender={'M','F'};//根据经验,这样可能方便一点 
struct Per{
	int grade;
	char name[15];
	char gender;//性别直接用整型表示吧 
	char id[15];
}temp,ansm,ansf;//这样一看,好像和1006差不多 
int main(){
	#ifdef LOCAL
	freopen("A1036data.in","r",stdin);
	freopen("A1036data.out","w",stdout);
	#endif
	int n,m=0,f=0;//男生和女生初始都是0个人 
	scanf("%d",&n);
	ansm.gender='M';//其实gender变量可以不需要的
	ansm.grade=100;//因为寻找的是男生的最小成绩
	ansf.gender='F';
	ansf.grade=0; 
	while(n--){
		scanf("%s %c %s %d",temp.name,&temp.gender,temp.id,&temp.grade);//注意这个地方数组不要用@ 
	if(temp.gender=='M'){
		m++;
		if(temp.grade<ansm.grade){
			ansm=temp;
		}
	}
	else{
		f++;
		if(temp.grade>ansf.grade){
			ansf=temp;
		} 
	} 
	}
	//输出
	if(m==0&&f==0) 
	{
		printf("Absent\n");
		printf("Absent\n");
		printf("NA");
		return 0;
	}
	if(m==0)
		{
			printf("%s %s\n",ansf.name,ansf.id);
			printf("Absent\n");
			printf("NA");
			return 0;
		}	
	if(f==0)
		 {
		 	printf("Absent\n");
			 printf("%s %s\n",ansm.name,ansm.id);
		 	printf("NA");
		 	return 0;
		 }
	printf("%s %s\n",ansf.name,ansf.id);
	printf("%s %s\n",ansm.name,ansm.id);
	printf("%d\n",ansf.grade-ansm.grade);
	return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
马丁路德金的"I have a dream"节选存放在"freedom.txt"中: I have a dream that one day this nation will rise up, live up to the true meaning of its creed: “We hold these truths to be self-evident; that all men are created equal.” I have a dream that one day on the red hills of Georgia the sons of former slaves and the sons of former slave-owners will be able to sit down together at the table of br otherhood. I have a dream that one day even the state of Mississippi, a state sweltering with th e heat of injustice, sweltering with the heat of oppression, will be transformed into an oasis of freedom and justice. I have a dream that my four children will one day live in a nation where they will no t be judged by the color if their skin but by the content of their character. I have a dream today. I have a dream that one day down in Alabama with its governor having his lips drippin g with the words of interposition and nullification, one day right down in Alabama li ttle black boys and black girls will be able to join hands with little white boys and white girls as sisters and brothers. I have a dream today. I have a dream that one day every valley shall be exalted, every hill and mountain sh all be made low, the rough places will be made plain, and the crooked places will be made straight, and the glory of the Lord shall be revealed, and all flesh shall see i t together. 编程实现词汇表,计算每一个单词出现的次数,大小写不区分,输出到"dic.txt" 文件保存。
最新发布
06-01
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值