http://v.youku.com/v_show/id_XMjU4NTcwMDIw.html
[b][flash=480,400]http://player.youku.com/player.PHP/sid/XMjU4NTcwMDIw/v.swf[/flash][/b]
[b][flv=480,400][b][flash=480,400]http://player.youku.com/player.PHP/sid/XMjU4NTcwMDIw/v.swf[/flash] [/b][/flv]
[/b]
看完了吧,再看一篇,,发现这个都是倒序向前比较,步长是span。
自己强化学习一下:
- PublicClassForm1
- PrivateSubButton1_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton1.Click
- ListBox1.Items.Clear()
- ListBox2.Items.Clear()
- Dimi,j,spanAsShort
- Dima(10)AsString,tempAsString
- Randomize()
- Fori=0Toa.Length-1
- a(i)=Int(10*Rnd())
- ListBox1.Items.Add(a(i))
- Next
- span=a.Length\2
- DoWhilespan>0
- Fori=spanToa.Length-1
- Forj=i-spanTo0Step-span
- Ifa(j)<=a(j+span)ThenExitFor
- temp=a(j)
- a(j)=a(j+span)
- a(j+span)=temp
- Next
- span=span\2
- Loop
- ListBox2.Items.Add(a(i))
- EndSub
- EndClass