CODE: [Copy to clipboard]
s=inputbox("以空格隔开:","请输入一组数:","10 17 2007 1 30")
if s="" then wscript.quit
r=split(s, " ", -1, 1)
x=ubound(r)
for i=1 to x step 1
t=r(i)
j=i-1
do while t<r(j)
r(j+1)=r(j)
j=j-1
if j=-1 then exit do
loop
r(j+1)=t
next
msgbox join(r," ")
[CODE: [Copy to clipboard]
'''''''' 直接插入排序 ''''''''
'''''''' s11ss 2007-10-17 ''''''''
'接受输入:
s=inputbox(vbcrlf&vbcrlf&"以空格隔开:","请输入一组数:","10 17 2007 15 40")
if s="" then wscript.quit
r=split(s," ")
x=ubound(r)
'把字符串转换为Double 子类型
for i=0 to x
r(i)=cdbl(r(i))
next
'直接插入排序:
for i=1 to x
t=r(i)
j=i-1
do while t<r(j)
r(j+1)=r(j)
j=j-1
if j=-1 then exit do
loop
r(j+1)=t
next
'输出结果:
inputbox vbcrlf&vbcrlf&"按升序排列是:",,join(r," ")