游客 Signup | Login
中文 | En

1721 - 中级第一课——所有偶数的平均值

 编程计算所有输入的数中偶数的平均值。输入数据以-1结束。

Input

一行,若干个数

Output

 一行,一个数,保留两位小数

Examples

Input

12 21 12 3 9 12 -1

Output

12.00

Solution C++

#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int x,t=0;
	double ans=0;
	while (cin>>x && x!=-1)
		if (x%2==0)
		{
			ans+=x;
			t++;
		}
	printf("%.2lf\n",ans/t);
	return 0;
}
Time Limit 1 second
Memory Limit 128 MB
Discuss Stats
上一题 下一题