#include
#define M 100
void main()
{
float a[M], average, sum = 0.0;
int i;
printf ("输入%d个数:\n", M);
for (i=0; i{
scanf ("%f", &a[i]);
sum += a[i];
}
average = sum / M;
printf ("平均值是: %.2f\n", average); //精确到小数点后两位
printf ("每个数与平均值的差值:\n");
for (i=0; iprintf ("%.2f ", a[i]-average); //精确到小数点后两位
printf ("\n");
}
#include
int main()
{int i;
float s=0,a[100],av;
printf("请输入100个数:");
for(i=0;i<100;i++)
{
scanf("%f",&a[i]);
s+=a[i];
}
av=s/100.0;
printf("平均值=%f\t各数与平均值的差为:\n");
for(i=0;i<100;i++)
{
printf("%6.2f",a[i]-av);
if(i%10==9)printf("\n");
}
return 0;
}