B1004 成绩排名 (20分)

B1004 成绩排名 (20分)

#include<cstdio>
struct student{
	char name[11];
	int id[11];
	int score;
}t,max,min;
int main()
{
	int n;
	scanf("%d",&n);
	max.score=-1;
	min.score=101;
	for(int i=0;i<n;i++)
	{
		scanf("%s%s%d",t.name,t.id,&t.score);
		if(t.score>max.score)max=t;
		if(t.score<min.score)min=t;
	}
	printf("%s %s\n",max.name,max.id);
	printf("%s %s\n",min.name,min.id);
	return 0;
}

注意:

1、字符数组大小最少是11,因为最后一位需要预留给'\0'所以数组大小必须比题目要求的大小最少打一位。

发布了61 篇原创文章 · 获赞 0 · 访问量 595

猜你喜欢

转载自blog.csdn.net/qq_38054511/article/details/103939164
今日推荐