【题目描述】
输入一些整数,求出它们的最小值、最大值和平均值(保留3位小数)。输入保证这些数都是不超过1000的整数。
【输入】
一行,若干个整数。
【输出】
一行,即,最小值、最大值和平均值(保留3位小数)。
【输入样例】
1 2 3
【输出样例】
1 3 2.000
【提示】
【数据范围】
数据个数不超过100。
#include<iostream>
using namespace std;
#include<cstdio>
int main()
{
int x,n=0,min=1000,max=-9999;
double s=0;
while(scanf("%d",&x)==1)
{
s=s+x;
if(x<min)
{
min=x;
}
if(x>max)
{
max=x;
}
n++;
}
printf("%d %d %.3f",min,max,s/n);
return 0;
}