解题思路:
无
注意事项:
无
参考代码:
#include<stdio.h>
#include<malloc.h>
typedef struct _Student
{
char num[10];
char name[10];
int Chinese;
int Maths;
int English;
}Student;
int main()
{
int n = 0;
int aver_Chinese = 0, aver_Maths = 0, aver_English = 0;
scanf("%d", &n);
Student* people = (Student*)malloc(sizeof(Student) * n);//people数组用于记录每位同学的信息
int *sum= (int*)malloc(sizeof(int) * n);//sum数组用于记录总分
for (int i = 0; i < n; i++)
{
scanf("%s %s %d %d %d", (people+i)->num, (people + i)->name, &(people + i)->Chinese, &(people + i)->Maths, &(people + i)->English);
aver_Chinese += (people + i)->Chinese;
aver_Maths += (people + i)->Maths;
aver_English += (people + i)->English;
*(sum + i) = (people + i)->Chinese + (people + i)->Maths + (people + i)->English;
getchar();
}
aver_Chinese /= n;
aver_Maths /= n;
aver_English /= n;
printf("%d %d %d\n", aver_Chinese, aver_Maths, aver_English);
int k = 0;
int max = *(sum + 0);
for (int i = 0; i < n; i++)
{
if (*(sum + i) > max)
{
max = *(sum + i);
k = i;//用k记录最大总分的下标
}
}
printf("%s %s %d %d %d", (people + k)->num, (people + k)->name, (people + k)->Chinese, (people + k)->Maths, (people + k)->English);
free(people);
free(sum);
return 0;
}
0.0分
1 人评分
C语言网提供由在职研发工程师或ACM蓝桥杯竞赛优秀选手录制的视频教程,并配有习题和答疑,点击了解:
一点编程也不会写的:零基础C语言学练课程
解决困扰你多年的C语言疑难杂症特性的C语言进阶课程
从零到写出一个爬虫的Python编程课程
只会语法写不出代码?手把手带你写100个编程真题的编程百练课程
信息学奥赛或C++选手的 必学C++课程
蓝桥杯ACM、信息学奥赛的必学课程:算法竞赛课入门课程
手把手讲解近五年真题的蓝桥杯辅导课程
发表评论 取消回复