死了也不知道错??
1 #include <stdio.h>2 struct information
3 {
4 int num;
5 char name;
6 float grade[3];
7 };
8 void input (float avag[],int n)
9 {
10 int i;
11 struct information student[n];
12 for(i=0;i<n;++i)
13 {
14 printf("输入第 %i 个学生的信息:",i);
15 scanf("%i-%c-%f/%f/%f",&student[i].num,&student[i].name,&student
[i].grade[0],&student[i].grade[1],&student[i].grade[2]);
16 avag[i] = (student[i].grade[0] + student[i].grade[1] + student[i
].grade[2]) / 3;
17 }
18 for(i=0;i<n;++i)
19 {
20 printf("第 %i 个学生的 avag[%d] = %.2f\n",i,i,avag[i]);
21 }
22 }
23 int average (float avag[],int n)
24 {
25 float TotalAverage,sum = 0;
26 int i;
27 for(i=0;i<n;++i)
28 sum += avag[i];
29 TotalAverage = sum / n;
30 return TotalAverage;
31 }
32 int max (float avag[],int n)
33 {
34 float maxi;
35 int i;
36 maxi = avag[0];
37 for(i=1;i<n;++i)
38 {
39 if(avag[i]>maxi)
40 maxi = avag[i];
41 }
42 return maxi;
43 }
44 int main (void)
45 {
46 int n,i;
47 printf("请输入要统计的学生个数 n = ");
48 scanf("%d",&n);
49 float avag[n],TotalAverage,maxi;
50 struct information student[n];
51 input (avag,n);
52 average (avag,n);
53 printf("总平均分数是 = %f",TotalAverage);
54 max (avag,n);
55 printf("最高分学生的信息是:[i].num = %i,student[i].name = %c,stu
dent[i].grade[0] = %f,student[i].grade[1] = %f,student[i].grade[2] = %f,
maxi = %i\n",student[i].num,student[i].name,student[i].grade[0],student[
i].grade[1],student[i].grade[2],avag[i]);
56 return 0;
57 }