找回密码
 加入
搜索
查看: 1095|回复: 4

看看下面的代码出来什么错误?

[复制链接]
发表于 2009-9-3 15:29:14 | 显示全部楼层 |阅读模式
本帖最后由 qinan1714 于 2009-9-4 13:19 编辑

Dim $a,$b,$c
Dim $t
$a=InputBox("First Number","Input")
$b=InputBox("Second Number","Seconnd")
$c=InputBox("Third Number","Third")

If $a>$b Then
$t=$a
$a=$b
$b=$t

EndIf
If $a>$c Then
$t=$a
$a=$c
$c=$t
EndIf
If $b>$c Then
$t=$b
$b=$c
$c=$t


EndIf
MsgBox(0,"三个数排序","从小到大依次为:"&$a&","&$b&","&$

一个很简单的问题比较三个数字大小,按照从小到大的顺序输出。
我输入了a=109,b=1008,c=110,怎么就出错了?输出的结果是1008,109,110。究竟是什么问题呢。
发表于 2009-9-3 16:19:34 | 显示全部楼层
#include<array.au3>
#include <_ArrayNaturalSort.au3>
Dim $number[3]
Dim $t
$number[0]=InputBox("First Number","Input",109)
$number[1]=InputBox("Second Number","Seconnd",9008)
$number[2]=InputBox("Third Number","Third",30)
_ArrayNaturalSort($number)
_ArrayDisplay($number,"从小到大排序")

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×

评分

参与人数 1金钱 +3 收起 理由
顽固不化 + 3

查看全部评分

发表于 2009-9-3 16:25:55 | 显示全部楼层
排序也需要动翻脑筋的,排序中有个“冒泡算法”,忘了。三个数还好说,如果有大量的数据没有个算法是不行的。
发表于 2009-9-3 16:36:38 | 显示全部楼层
MsgBox(0,"三个数排序","从小到大依次为:"&$a&","&$b&","&$    好像不对

MsgBox(0,"三个数排序","从小到大依次为:"& $a &"," & $b & "," &$c )

另外,此法不可靠,有些情况下,脚本能达到效果, a=109,b=1008,c=110 这却不行!

建议使用数组试试看看......
 楼主| 发表于 2009-9-3 17:38:53 | 显示全部楼层
谢谢给的意见,我再看看,好好研究研究!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-19 17:02 , Processed in 0.081265 second(s), 25 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表