srkp.net
当前位置:首页 >> vB,我知道是冒泡排序法,可是,F=truE 和F=FAlsE... >>

vB,我知道是冒泡排序法,可是,F=truE 和F=FAlsE...

不一定要那么多排序才能把那个数组排好 如果说,其中一次循环,没有发生一次排序,那证明数组已经排好了 那f还是为true,就可以直接退出循环,不用浪费资源了

f = True 这是将逻辑“真”赋值给f变量,当排序全部完成时,f肯定为真 重要是: If f Then Exit For End If 当f为真时,退出外循环,表示结束

就是比较数值,把大的或小的放在前面 比如,有一个数组a()包含{5,7,3,9,12,15,56}7个数 dim t as integer for i=0 to a.count-1 for j=i+1 to a.count-1 t=a(i) if a(i) a(i + 1)) Then '若是递减,改为a(i)

Private Sub Command1_Click() Dim a(5) As Double Dim i, j As Integer '给数组赋值 For i = 1 To 5 temp = InputBox(" 请输入" + Str(i) + "个数字", "输入") If IsNumeric(temp) Then '是数字就将数字赋值给数组 a(i) = temp Else '不是数字...

冒泡排序,在每一次比较的时候,如果发现相邻两数的次序不对,都会马上就把两数进行对调。 选择排序,则在比较过程中(内循环里面)并不进行对调,而是先记录下最小(大)数的下标,在一次扫描完成后再进行对调。所以它的效率会比冒泡的高一点。...

For i = 1 To 10 For j = 1 To 10 - i If a(j) > a(j + 1) Then temp = a(j + 1) a(j + 1) = a(j) a(j) = temp End If Next j Next i

如果五个号码为数组元素(1)到(5),正确的排序过程: 对于i = 1至4 对于L = 1到5 - 如果A(L)(L +1) N = A(L) A(L),= A(L +1) (L +1) = 结束如果下一页l 接下来,我 能够到第一台计算机来验证结果,然后分析程序。

Option Base 1 Private Sub Command1_Click() Dim a Dim b As Integer Dim i As Integer Dim j As Integer a = Array(6, 3, 7, 8, 2, 1) Print "排序前为"; For i = 1 To 6 Print a(i); Next i For i = 1 To 5 For j = 1 To 6 - i If a(j) > a(j...

Dim a(8) As Integer Dim cou As Integer Dim temp As Integer Sub shownum() Command1.Caption = a(1) Command2.Caption = a(2) Command3.Caption = a(3) Command4.Caption = a(4) Command5.Caption = a(5) Command6.Caption = a(6) Command7.C...

Private Sub Form_Click() Dim arr(1 To 10) As Integer, i As Integer, j As Integer, t As Integer For i = 1 To 10 Randomize arr(i) = Int(Rnd * 90) + 10 '10-99随机数 Next For i = 1 To 9 For j = i + 1 To 10 If arr(i) > arr(j) Then '...

网站首页 | 网站地图
All rights reserved Powered by www.srkp.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com