主题:[原创]高手指点
nyjw
[专家分:0] 发布于 2007-06-26 19:11:00
cls
input a,b,c
if a>b and a>c then
if b>c then print a,b,c
else print a,c,b
else
if b>a and b>c then
if a>c then print b,a,c else print b,c,a
else
if b>a then print c,b,a else print c,a,b
end if
end if
end
这个程序实现 的功能是输入三个数A,B,C,让它有大到小的顺序打印出来.
这个程序哪错了,请高用指点.
回复列表 (共7个回复)
沙发
moz [专家分:37620] 发布于 2007-06-26 20:00:00
去翻书看看IF的两种形式是怎样要求的。
板凳
&佑慧妹妹& [专家分:660] 发布于 2007-06-26 20:19:00
谢天谢地,毕业考试终于结束了,想着一个月来的艰苦奋斗终于有尽头了,而且暑假也没有作业!我现在相当的激动。现在,没什么事了,会常来玩的。
你程序的运行结果是错的
CLS
INPUT a, b, c
IF a > b AND a > c THEN
IF b > c THEN PRINT a, b, c ELSE PRINT a, c, b
ELSE
IF b > a AND b > c THEN
IF a > c THEN PRINT b, a, c ELSE PRINT b, c, a
ELSE
IF a < b THEN PRINT c, b, a ELSE PRINT c, a, b
END IF
END IF
END
现在这个应该是对的了
还有,楼上MOZ大哥,摆脱您不要惜字如金OK?这样会让那些初学者感到困惑不解的,没准有些小心眼的人认为您有难不救,会破坏您形象的。
3 楼
Matodied [专家分:7560] 发布于 2007-06-26 21:00:00
楼上的……
你倒快活了,一个暑假都没作业!我们明年这时候……但是今年还是有这么难的作业。
楼主:
[quote]if b>c then print a,b,c
[color=000080]else[/color] print a,c,b[/quote]
问题就出在这个ELSE上面。在块IF语句中,THEN后面不能加语句,否则会显示:
“ELSE without IF”
应该改为:
IF b>c THEN
PRINT a,b,c
ELSE
PRINT a,c,b
END IF
4 楼
Lovely哆啦 [专家分:1360] 发布于 2007-07-23 12:51:00
[quote]楼上的……
你倒快活了,一个暑假都没作业!我们明年这时候……但是今年还是有这么难的作业。
楼主:
[quote]if b>c then print a,b,c
[color=000080]else[/color] print a,c,b[/quote]
问题就出在这个ELSE上面。在块IF语句中,THEN后面不能加语句,否则会显示:
“ELSE without IF”
应该改为:
IF b>c THEN
PRINT a,b,c
ELSE
PRINT a,c,b
END IF
[/quote]
5 楼
剑圣风暴 [专家分:450] 发布于 2007-07-24 21:50:00
if的顺序错了
6 楼
yaoyusheng [专家分:460] 发布于 2007-07-26 12:36:00
cls
input "a,b,c:";a,b,c
If a > b Then
If b > c Then Print a; b; c
Else
t = a
a = b
b = t
End If
If b > c Then
Print a; b; c
Else
If a > c Then
Print a; c; b
Else
Print c; a; b
End If
End If
end
经测试,正确.
给我加30分.
7 楼
yaoyusheng [专家分:460] 发布于 2007-07-26 12:50:00
cls
input a,b,c
If a > b And a > c Then
If b > c Then
Print a, b, c
Else
Print a, c, b
End If
Else
If b > a And b > c Then
If a > c Then
Print b, a, c
Else
Print b, c, a
End If
Else
If b > a Then
Print c, b, a
Else
Print c, a, b
End If
End If
End If
END
把你的程序改成这样,也对.
经测试,正确.
再给我加20分.
我来回复