cgzy320 @ 2023-10-15 17:21:54
#include<stdio.h>
int main()
{
int n,x,s;
double m;
scanf("%d",&n);
for(int i=1;i<=n;i++){
scanf("%d\n",&x);
s+=x;}
m=s/n;
printf("%.2lf",m);
return 0;
}
**
by chienyu2009 @ 2023-10-15 17:23:06
m在求值时要先*1.0
by Lyrith_with_xQ @ 2023-10-15 17:25:10
@cgzy320 s被定义在main函数中的话,初始值就是一个随机值,需要先把s的值设为0才能用
by Zeze2014 @ 2023-12-23 10:03:34
s初始化为0 s或n需*1.0