#include<stdio.h>
#include<math.h>
#include<stdlib.h>
void main()
{
int i, j, sum=0;
float average[4];
int a[4][5]={80,84,78,81,82, 65,46,63,70,73, 87,93,95,82,88, 75,74,78,67,77};
printf("求每个人的平均成绩\n");
printf("\n");
for(i=0;i<4;i++)
{
for(j=0;j<5;j++)
{
sum=sum+a[i][j];
}
average[i]=sum/5;
sum=0;
}
printf("%.2f\t %.2f\t %.2f\t %.2f\n",average[0],average[1],average[2],average[3]);
printf("\n");
}
为什么精确度不是小数点后两位,而是小数点后都是0了?
正确的是这样的: