⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 冒泡法排序.frm

📁 各种排序查找法与一些优秀的算法,包括二分查找,利用递推公式计算(裴波拉契数列),冒泡法,递归调用,顺序查找,选择法,直接插入,直接排序等...个人珍藏..初学者可以拿来参考下..很不错
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   3075
   ClientLeft      =   60
   ClientTop       =   465
   ClientWidth     =   4680
   LinkTopic       =   "Form1"
   ScaleHeight     =   3075
   ScaleWidth      =   4680
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command1 
      Caption         =   "生成数组数组排序"
      Height          =   735
      Left            =   2520
      TabIndex        =   4
      Top             =   1920
      Width           =   855
   End
   Begin VB.TextBox Text2 
      Height          =   375
      Left            =   1200
      TabIndex        =   3
      Top             =   840
      Width           =   3015
   End
   Begin VB.TextBox Text1 
      Height          =   375
      Left            =   1200
      TabIndex        =   2
      Top             =   240
      Width           =   3015
   End
   Begin VB.Label Label2 
      AutoSize        =   -1  'True
      Caption         =   "排序后"
      Height          =   180
      Left            =   240
      TabIndex        =   1
      Top             =   840
      Width           =   540
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      Caption         =   "原始数组"
      Height          =   180
      Left            =   240
      TabIndex        =   0
      Top             =   360
      Width           =   720
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Base 1
Private Sub Command1_Click()
  Dim a(10) As Integer, i As Integer
  Randomize
  For i = 1 To 10
    a(i) = Int(100 * Rnd) + 1
    Text1.Text = Text1.Text & Str(a(i))
  Next i
  Call bubble_sort(a)
  For i = 1 To 10
    Text2.Text = Text2.Text & Str(a(i))
  Next i
End Sub

Private Sub bubble_sort(a() As Integer)
  Dim i As Integer, temp As Integer
  Dim ub As Integer, switch As Boolean
  ub = UBound(a)
  switch = True
  Do While switch
    switch = False
    ub = ub - 1
    For i = 1 To ub
      If a(i) > a(i + 1) Then
        switch = True
        temp = a(i)
        a(i) = a(i + 1)
        a(i + 1) = temp
      End If
    Next i
  Loop
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -