输入输出函数实现
值得注意的点是强制转换 (double )类型
void InputArr( struct student arr[], int n, int m )
{
int i;
for(i=0;i<n;i++)
{
scanf("%ld %s",&arr[i].id,arr[i].name);
for(int j=0;j<m;j++)
{
scanf("%d",&arr[i].score[j]);
}
}
}
void OutputArr( struct student arr[], int n, int m )
{
double average;
for(int i=0;i<n;i++)
{
average=(double)(arr[i].score[0]+arr[i].score[1]+arr[i].score[2])/m;
printf("%8ld%8s%4d%4d%4d%6.1f\n",arr[i].id,arr[i].name,arr[i].score[0],arr[i].score[1],arr[i].score[2],average);
}
}