90分,第一个WA
查看原帖
90分,第一个WA
1581342
L19070850630楼主2024/12/1 22:21
#define _CRT_SECURE_NO_WARNINGS

#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#include<math.h>

typedef struct Student {
	char name[20];
	int Chinese;
	int Math;
	int English;
}Student;
int main(void) {
	int n;
	scanf("%d", &n);
	Student* student = (Student*)malloc(sizeof(Student) * n);
	int* sum = (int*)calloc(n, sizeof(int));
	int max = 0;
	int place;
	for (int i = 0; i < n; i++) {
		scanf("%s %d %d %d", &student[i].name, &student[i].Chinese, &student[i].Math, &student[i].English);
		sum[i] = student[i].Chinese + student[i].Math + student[i].English;
		if (sum[i] > max) { max = sum[i], place = i; }
	
	}
	printf("%s %d %d %d", student[place].name, student[place].Chinese, student[place].Math, student[place].English);

	return 0;
}
2024/12/1 22:21
加载中...