scanf

/*不用数组也行,scanf返回成功输入变量的个数,按回车+ctrl+z+回车*/
#include<iostream>
using namespace std;
int main()
{
    int x,n=0,min,max,s=0;
    scanf("%d",&x);
    s=min=max=x;
    n=1;
    while(scanf("%d",&x)==1)
    {
        s+=x;
        if(x<min)min=x;
        if(x>max)max=x;
        n++;
    }
    printf("%d %d %.3lf\n",min,max,(double)s/n);
    return 0;
}

 

posted @ 2012-11-02 16:30  myth_HG  阅读(140)  评论(0编辑  收藏  举报