c语言,全部WA,但自己测试没有问题,求助大佬
查看原帖
c语言,全部WA,但自己测试没有问题,求助大佬
1566055
h135711楼主2024/12/22 00:28
#include <stdio.h>
#include <stdlib.h>
struct Student {
	char name[10];
	int c;
	int m;
	int e;
};
int main()
{
	char ch;
	int n,sum=0,j;
	struct Student *a,*b,*c;
	scanf("%d",&n);
	getchar();
	a = (struct Student*)malloc(sizeof(struct Student)*n);
	b = a;
	c =a;
	for (int i=0;i<n;i++) {
		while((ch = getchar())!=' ') {
			(*a).name[j] = ch;
			j++;
		}
		j = 0;
		scanf("%d",&(a->c));
		scanf("%d",&(a->m));
		scanf("%d",&(a->e));
		if(a->c + a->m + a->e > sum){
			sum = a->c + a->m + a->e;
			b = a;
		}
		getchar();
		a++;
	}
	printf("%s %d %d %d",b->name,b->c,b->m,b->e);
	free(c);
	return 0;
}
2024/12/22 00:28
加载中...