编一程序,是用单分支的if语句形式,求a,b,c三个整数的中间值.

来源:百度知道 编辑:UC知道 时间:2024/05/08 10:06:52
例如 a,b,c是456则输出5
2楼的执行不了啊,小问题很多.

main(inta,int b ,int c)
{
int mid;
printf(Please into three number:)
scanf("a b c",&a&b&c);
if((a>b&&a<c)||(a<b&&a>c)) mid=a;
else if((b>a&&b<c)||(b<a&&b>c)) mid=b;
else mid=c;
return mid;
}

一楼的我觉得判断少了,你觉得你的算法,如果
a=2 b=3 c=1时,会输出什么结果?

多写几个if语句好了
if a>b and a<c then print a endif
if b>a and b<c then print b endif
if c>a and c<b then print c endif
.....