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

2023-07-25 20:08发布

#include void main(){int a,b,c,d,e;scanf(%d,&a);scanf(%d,&b);scanf(

#include void main(){int a,b,c,d,e;scanf("%d",&a);scanf("%d",&b);scanf(
2条回答
2023-07-25 20:25 .采纳回答
#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);

一周热门 更多>