20分,求帮助(倒下)
查看原帖
20分,求帮助(倒下)
1349194
nulidexiaozhou楼主2024/6/20 11:15

代码如下

#include<stdio.h>
typedef struct{
	char name[100];
	int chi;
	int math;
	int eng;
} stu;
int main()
{
	int n;
	stu s[1000];
	int arr[1000];
	int flat=0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%s%d%d%d", s[i].name, &s[i].chi, &s[i].math, &s[i].eng);
	}
	for (int i = 0; i < n; i++)
	{
		int sum = s[i].chi + s[i].math + s[i].eng;
		arr[i] = sum;
	}
	for (int i = 0; i < n; i++)
	{
		int max = arr[0];
		if (max < arr[i])
		{
			max = arr[i];
			flat = i;
		}
	}
	printf("%s %d %d %d", s[flat].name, s[flat].chi, s[flat].math, s[flat].eng);
	return 0;
}


2024/6/20 11:15
加载中...