解题思路:
无
注意事项:
无
参考代码:
#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语言代码)浏览:711 |
哥德巴赫曾猜测 (C语言代码)浏览:1149 |
C语言程序设计教程(第三版)课后习题6.2 (C语言代码)浏览:716 |
简单的a+b (C语言代码)浏览:574 |
出圈】指针malloc版浏览:377 |
演讲大赛评分 (C语言代码)浏览:1696 |
Tom数 (C语言代码)浏览:598 |
C二级辅导-统计字符 (C语言代码)浏览:695 |
最好的,浏览:601 |
1392题解(大数相加)浏览:640 |