#include
#define size 30
#define size1 5
void Total(int (*pa)[5],int sum[],float average[],int m,int n);
void Print(int *pa,int sum[],float average[],int m,int n);

int main()
{
int n;
int a[size][size1];
int sum[size];
float average[size];
int m;
int i;
int j;
do
{
printf("how many students:");
scanf("%d",&m);
printf("how many course:");
scanf("%d",&n);
}while(m<=0||m>30||n<=0||n>5);
printf("input score:\n");
for(i=0;i<=m-1;i++)
{
for(j=0;j<=n-1;j++)
{
scanf("%d",&a[i][j]);
}
}
for(i=0;i<=m-1;i++)
for(j=0;j<=n-1;j++)
printf("%5d",a[i][j]);

``````Total(a,sum,average,m,n);
Print(*a,sum,average,m,n);
return 0;
``````

}

void Total(int (*pa)[5],int sum[],float average[],int m,int n)
{
int i,j;
for(i=0;i<=m-1;i++)
{
sum[i]=0;

``````    for(j=0;j<=n-1;j++)
{
sum[i]+=pa[i][j];
printf("%5d ",pa[i][j]);
}
printf("%5d",sum[i]);
average[i]=(float)sum[i]/n;
}
return ;
``````

}

void Print(int *pa,intrf sum[],float average[],int m,int n)
{
int i;
int j;
printf("result:\n");
for(i=0;i<=m-1;i++)
{
for(j=0;j<=n-1;j++)
{
printf("%4d\t",pa[i*n+j]);
}
printf("%5d\t%6f\t\n",sum[i],average[i]);
}
return ;
}

1个回答

`````` void Total(int (*pa)[5],int sum[],float average[],int m,int n)

``````
qq_43323545 还有后面的一个我用*pa定义，能帮忙看一下有什么错吗

qq_43323545 为啥?2个不是一个意思吗？