#include
int main(void)
{
float num[81],numa=0;
int i=0,n=0;
do
{
printf("请汪慧输入第%d个数(0退出):___\b\b\b",i+1);
scanf("族陆%f",&num[i]);
i++;
}while(num[i-1]!=0);
for(n=0;n<=i-1;n++)
{
numa+=num[n];
}
printf("平均数是:%.3f",numa/(i-1));
return 0;
}
看不懂兆陵顷追问我。
#include
int get_avg(int a[], int len)
{
int sum = 0, i;
if (len == 0)
{
printf("error\n");
return 0;
}
for (i=0; i{
sum += a[i];
}
滑饥 return (sum/len);
}
int main()
{
int a[64] = {0}, i = 0;
int itemp;
do
{
scanf("%d", &itemp);
if (itemp != 0)
旦让哪模码{
a[i++] = itemp;
}
} while (itemp != 0);
printf("avg is %d\n", get_avg(a, i));
return 1;
}
int main()
{
int x,count=0;
橘老 float ave=0.0;
do
{
scanf("圆信升%d",&x);
ave=ave+x;
count++;
坦唯 }while(x!=0);
count--;
ave=ave/count;
printf("%f",ave);
return 0;
}