输入一些整数,求最大值最小值和平均值
#include<stdio.h>
int main(){
int x,n=0,min,max,s=0;
while(scanf("%d",&x)==1)
{
s+=1;
if(x<min) min=x;
if(x>max) max=x;
n++;
}
printf("%d %d %.3f\n",min,max,(double)s/n);
return 0;
}
#include<stdio.h>
int main(){
int x,n=0,min,max,s=0;
while(scanf("%d",&x)==1)
{
s+=1;
if(x<min) min=x;
if(x>max) max=x;
n++;
}
printf("%d %d %.3f\n",min,max,(double)s/n);
return 0;
}
相关推荐