解题思路:
无
注意事项:
无
参考代码:
#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 人评分
简单的a+b (C语言代码)浏览:760 |
C语言训练-求函数值 (C语言代码)浏览:580 |
C语言程序设计教程(第三版)课后习题11.8 (C语言代码)浏览:886 |
C语言训练-计算t=1+1/2+1/3+...+1/n (C语言代码)浏览:907 |
矩阵加法 (C语言代码)浏览:1723 |
简单的a+b (C语言代码)浏览:546 |
杨辉三角 (C语言代码)浏览:484 |
printf基础练习2 (C语言代码)浏览:508 |
复数求和 (C语言代码)浏览:927 |
C语言程序设计教程(第三版)课后习题6.3 (C语言代码)浏览:476 |