标签:com put stdio.h average nbsp print alt mamicode student
#include<stdio.h>
int average(int arr[5][3])
{
int m,n,i,j,add=0,subject=1,sum=0,student=1;
for(i=0;i<5;i++)
{
sum=0;
for(j=0;j<3;j++)
{
sum+=arr[i][j];
}
printf("student%d:%f\n",student,(float)sum/3);
student++;
}
for(m=0;m<3;m++)
{
add=0;
for(n=0;n<5;n++)
add+=arr[n][m];
printf("subject%d:%f\n",subject,(float)add/5);
subject++;
}
return 0;
}
int main()
{
int arr[5][3];
int a,b;
printf("input scores:");
for(a=0;a<5;a++)
for(b=0;b<3;b++)
scanf("%d",&arr[a][b]);
average(arr);
return 0;
}
标签:com put stdio.h average nbsp print alt mamicode student
原文地址:https://www.cnblogs.com/P201821440028/p/10819945.html