[QUOTE]
void aver(float a[][5]) /* 类型默认成了int 但是声明时确实float */
{int i,j;
float sum,ave;
sum=0.000000;
for(i=0;i<9;i++)
{for(j=0;j<4;j++)
sum=sum+a[i][j];
ave=sum/5;
printf("students %ds average scroes is %f",i,ave);
}
void meimen(float a[][5]) /* 类型默认成了int 但是声明时确实float */
{int i,j;
float sum,pingjun;
sum=0.000000;
for(j=0;j<4;j++)
{for(i=0;i<9;i++)
sum=sum+a[i][j];
pingjun=sum/10;
printf("subjects %ds average scroes is %f",j,pingjun);
}
void fc(float a[][5]) /* 类型默认成了int 但是声明时确实float */
{int i,j;
float sum,a,b,c,m; /*系统可能把a认为成了数组名,若改成其他的就不出现问题*/
sum=0.000000 /*;*/
b=0.000000;
c=0.000000;
for(i=0;i<9;i++)
{for(j=0;j<4;j++)
sum=sum+a[i][j];
ave=sum/5;
a=ave*ave; /*浮点型不能这样相乘*/
b=b+ave;
c=c+a; /*浮点型不能这样相加*/
}
m=c/10-(b/10)*(b/10);
printf("The fangcha is %f",m);
}
main()
{ float aver(float a[][5]);
float meimen(float a[][5]);
float fc(float a[][5]);
flaot a[10][5]; /*float*/
int i,j;
printf("Please input 10 students 5 subjects scores:");
for(i=0;i<9;i++) /*这分明是9个量 下面也是*/
for(j=0;j<4;j++)
scanf("%f",&a[i][j]);
aver(a);
meimen(a);
fc(a);
}
[/QUOTE]
我就能改这么多,下面是我改得正确的程序。
float aver(float a[][5])
{int i,j;
float sum,ave;
sum=0.000000;
for(i=0;i<9;i++)
{for(j=0;j<4;j++)
sum=sum+a[i][j];
ave=sum/5;
printf("students %ds average scroes is %f",i,ave);
}
return(0);
}
float meimen(float a[][5])
{int i,j;
float sum,pingjun;
sum=0.000000;
for(j=0;j<4;j++)
{for(i=0;i<9;i++)
sum=sum+a[i][j];
pingjun=sum/10;
printf("subjects %ds average scroes is %f",j,pingjun);
}
return(0);
}
float fc(float a[][5])
{int i,j,ave;
float sum,p,b,c,m;
sum=0.000000;
b=0.000000;
c=0.000000;
for(i=0;i<9;i++)
{for(j=0;j<4;j++)
sum=sum+a[i][j];
ave=sum/5;
p=ave*ave;
b=b+ave;
c=c+p;
}
m=c/10-(b/10)*(b/10);
printf("The fangcha is %f",m);
return(0);
}
main()
{ float aver(float a[][5]);
float meimen(float a[][5]);
float fc(float a[][5]);
float a[10][5];
int i,j;
printf("Please input 10 students 5 subjects scores:");
for(i=0;i<=9;i++)
for(j=0;j<=4;j++)
scanf("%f",&a[i][j]);
aver(a);
meimen(a);
fc(a);
}