#include
int main()
{
int n=1, t, max, min, s=0;
scanf("%d",&max);
s=min=max;
while(~scanf("%d",&t))
{
n++;
s+=t;
if(min>t)min=t;
if(max}
printf("%d %d %.3f\n", min, max, s/(float)n);
return 0;
}
大一C语言,
#include "stdio.h"
int main(int argv,char *argc[]){
int n,s,m,max,min;
max=s=m=0;
min=1001;
printf("Input some positive integers, separated by ' ', ENTER end...\n");
while(1){
scanf("%d",&n);
if(n>=0 && n<=1000){
s+=n;
m++;
if(maxmax=n;
if(min>n)
min=n;
}
else
break;
if(getchar()=='\n')
break;
}
printf("The MAX is %d\nThe MIN is %d\n",max,min);
printf("The AVERAGE are %.3f\n",s/(m+0.0));
return 0;
}
运行样例: