• 1200 正数的平均值

    Time Limit : 2000/1000 MS(Java/Others) | Memory Limit : 65536/32768 KB(Java/Others)

    Submits : 16141 | Solved : 7429

    Description

    输入10个实数,计算并输出所有大于0的数的平均值。

    Input

    输入10个实数。

    Output

    计算大于0的数的平均值。

    Sample Input

    -5 2 -6 9 -4 -2 0 6 1 10
    

    Sample Output

    5.60

    Template

    #include<stdio.h>
    #define N 10
    @-@  //设计函数实现求平均
    int main()
    {
    	double a[N],res;
    	int i;
    	for(i=0;i<N;i++)
    	{
    		scanf("%lf",&a[i]);
    	}
        res=ave(a,N);   //调用函数求大于0的数的平均值
    	printf("%.2f\n",res);
    	return 0;
    }

    HINT

    输出精确到小数点后2位。

    Source

    NBU OJ

    [ Top ] | [ Submit ] | [ Statistics ] | [ Standing ]