Vb排序~解释

来源:百度知道 编辑:UC知道 时间:2024/09/23 00:30:10
if a<b then t=a:a=b:b=t
if a<c then t=a:a=c:c=t
if b<c then t=b:b=c:c=t
print a,b,c
帮我解释下意思,看还有没有别的方法??将A,B,C从小到大排序。

这是最简方法,但是不是你说的从小到大
而是从大到小,解释如下

'如果a小于b,交换ab(保证a大于b)
if a<b then t=a:a=b:b=t
'如果a小于c,交换ac(保证a大于c,加上a大于b,保证a最大)
if a<c then t=a:a=c:c=t
'如果b小于c,交换bc(保证b大于c)
if b<c then t=b:b=c:c=t

一楼正解!