c语言程序题:从键盘上任输入三个实数,求出最大数和最小数的和值,

2022-12-17 05:01发布

#includemain(){ float a,b,c,max,min,sum,average; printf(请输入三个实数,

#includemain(){ float a,b,c,max,min,sum,average; printf("请输入三个实数,
2条回答
2022-12-17 05:07
#include<stdio.h>
main()
{
float a,b,c,max,min,sum,average;
printf("请输入三个实数,以空格隔开");
scanf("%f %f %f",&a,&b,&c);
max=a;
min=a;
if(b>max) max=b;
if(b<min) min=b;
if(c>max) max=c;
if(c<min) min=c;
sum=min+max;
average=sum/2;
printf("和值为%f\n",sum);
printf("平均值为%f\n",average);
}

int a,b,c,MAX,MIN;sancf("%d%d%d",&a,&b,&c);MAX=MIN=a;if(MAX < b)MAX = b;if(MIN > b) MIN = b;if(MAX < c) MAX = c;if(MIN > c) MIN = c;printf("和=%d,平均=%f",MIN+MAX,((folat)(MAX+MIN))/2);

一周热门 更多>