VERSION 5.00 Begin VB.Form Form1 BorderStyle = 1 'Fixed Single Caption = "Form1" ClientHeight = 3135 ClientLeft = 150 ClientTop = 720 ClientWidth = 7695 LinkTopic = "Form1" MaxButton = 0 'False MinButton = 0 'False ScaleHeight = 3135 ScaleWidth = 7695 StartUpPosition = 3 'Windows Default Begin VB.Timer Timer1 Left = 5040 Top = 1920 End Begin VB.PictureBox Picture1 Appearance = 0 'Flat BackColor = &H00C0C0C0& ForeColor = &H80000008& Height = 1815 Left = 0 ScaleHeight = 1785 ScaleWidth = 7665 TabIndex = 6 Top = 0 Width = 7695 End Begin VB.HScrollBar HScroll1 Height = 135 LargeChange = 10 Left = 2040 Max = 100 Min = 20 TabIndex = 4 Top = 3000 Value = 20 Width = 5655 End Begin VB.CommandButton Command3 Caption = "Выход" Height = 255 Left = 0 TabIndex = 3 Top = 2880 Width = 2055 End Begin VB.OptionButton Option2 Caption = "Простые вставки" Height = 255 Left = 120 TabIndex = 2 Top = 2280 Width = 1935 End Begin VB.OptionButton Option1 Caption = "Пузырёк" Height = 255 Left = 120 TabIndex = 1 Top = 1920 Value = -1 'True Width = 1935 End Begin VB.CommandButton Command1 Caption = "Сортировать" Height = 255 Left = 0 TabIndex = 0 Top = 2640 Visible = 0 'False Width = 2055 End Begin VB.Label Label4 AutoSize = -1 'True Height = 195 Left = 2760 TabIndex = 9 Top = 2280 Width = 45 End Begin VB.Label Label3 Alignment = 1 'Right Justify BackStyle = 0 'Transparent Caption = "КПД:" BeginProperty Font Name = "MS Sans Serif" Size = 12 Charset = 204 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 375 Left = 2160 TabIndex = 8 Top = 2040 Width = 615 End Begin VB.Label Label2 AutoSize = -1 'True Height = 195 Left = 2760 TabIndex = 7 Top = 1920 Width = 45 End Begin VB.Label Label1 Alignment = 1 'Right Justify BackStyle = 0 'Transparent Caption = "20" BeginProperty Font Name = "MS Sans Serif" Size = 18 Charset = 204 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 375 Left = 6720 TabIndex = 5 Top = 2640 Width = 975 End Begin VB.Menu File Caption = "Файл" Begin VB.Menu Exit Caption = "Выход" End End Begin VB.Menu Actions Caption = "Действия" Begin VB.Menu Met Caption = "Метод сортировки" Begin VB.Menu Bubles Caption = "Пузырек" End Begin VB.Menu Pastes Caption = "Простые вставки" End End Begin VB.Menu Create Caption = "Создать массив" End Begin VB.Menu Sort Caption = "Сортировать" Enabled = 0 'False End End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Dim k As Integer, i As Double, j As Double, Tmp As Double Dim n As Integer, r As String, Arr() As Integer Private Sub Bubles_Click() Option1.Value = True End Sub Private Sub Command1_Click() If Option1.Value = True Then Buble Else Paste End Sub Private Sub Command3_Click() End End Sub Private Sub Create_Click() k = InputBox("Введите количество значений (от 20 до 100)", "Создаем массив", 20) If Val(k) < 20 Then k = 20 ElseIf Val(k) > 100 Then k = 100 Else k = Val(k) End If HScroll1.Value = 20 HScroll1.Value = 100 HScroll1.Value = k End Sub Private Sub Exit_Click() End End Sub Private Sub HScroll1_Change() start Command1.Visible = True Sort.Enabled = True End Sub Sub Buble() r = Now n = 0 Timer1.Interval = 10 For i = 0 To UBound(Arr) For j = 0 To UBound(Arr) - 1 - i If Arr(j) <= Arr(j + 1) Then Tmp = Arr(j) Arr(j) = Arr(j + 1) Arr(j + 1) = Tmp Picture1.Cls For t = 0 To UBound(Arr) Picture1.Line (t + 1, 0)-(t + 1, Arr(t)) Next If r <> Now Then n = n + 1 r = Now End If End If Next j Next i Timer1.Interval = 0 Label2 = Label1 & " за " & n & " сек." End Sub Sub start() Label1 = HScroll1.Value ReDim Arr(HScroll1.Value - 1) As Integer For i = 0 To UBound(Arr) Arr(i) = Fix(Rnd * 90 + 10) Next Max = Arr(0) For i = 1 To UBound(Arr) If Max < Arr(i) Then Max = Arr(i) Next Picture1.Cls Picture1.Scale (0, Max + 10)-(UBound(Arr) + 2, 0) Picture1.DrawWidth = 400 / (UBound(Arr) + 1) For i = 0 To UBound(Arr) Picture1.Line (i + 1, 0)-(i + 1, Arr(i)) Next End Sub Sub Paste() r = Now n = 0 Timer1.Interval = 10 i = 1 Do j = 0 Do If Arr(i) >= Arr(j) Then k = i Tmp = Arr(i) Do Arr(k) = Arr(k - 1) k = k - 1 Picture1.Cls For t = 0 To UBound(Arr) Picture1.Line (t + 1, 0)-(t + 1, Arr(t)) Next If r <> Now Then n = n + 1 r = Now End If Loop Until Not k > j Arr(j) = Tmp j = i Else j = j + 1 End If Loop Until Not j < i i = i + 1 Loop Until Not i <= UBound(Arr) Timer1.Interval = 0 Label4 = Label1 & " за " & n & " сек." End Sub Private Sub Pastes_Click() Option2.Value = True End Sub Private Sub Sort_Click() Command1_Click End Sub