int score =0;
int i ;
double sum=0,avg ;
for ( i=0;;i++ ) //循环退出条件这里不写
{
scanf("%d", &score );
if ( score == -1 ) //输入为-1结束循环
break ;
sum += score ; //累加
}
avg=sum/ i ; //平均值
#include "stdio.h"
int main()
{
float a = 0;
float sum = 0;
int k =0;
/*while (scanf("%f",&a)!=EOF&&a!=-1)
{
k++;
sum+= a;
}*/
for (;a!=-1;k++)
{
sum+= a;
scanf("%f",&a);
}
printf("%f\n",sum/k);
return 0;
}
#include
int main()
{
int cnt = 0;
int sum = 0;
int num;
for(;;)
{
scanf("%d",&num);
if (-1==num)
break;
sum += num;
cnt++;
}
printf("%f\n",sum*1.0/cnt);
return 0;
}