任意8个数求和,求平均值。各位大神,哪里错了啊?
任意8位数求和、求平均值#include <stdio.h>
#include <stdlib.h>
int main()
{int x[8],s=0,i;
for(i=0;i<8;i++);
scanf("%d",&x[i]);
printf("%d\n",s+x[i]);
printf("%.2f\n",(s+x[i])/8.0);
return 0;
}
2016-05-11 17:54
程序代码:#include <stdio.h>
#include <stdlib.h>
int main()
{
int x[8], s = 0, i;
for (i = 0; i < 8; i++)//多了个冒号
{
scanf("%d", &x[i]);
s += x[i];
}
printf("%d\n", s);
printf("%.2f\n", (s) / 8.0);
return 0;
}
2016-05-11 18:02
2016-05-11 19:22