|
B.34.1.
Sub AA()
Dim Mass(0 To 10) As Integer
Dim k As Integer
Dim m As Integer
Dim s As String
Dim a As Integer
Open "e:\test_in.txt" For Input As #1
For k = 1 To 10
Input #1, Mass(k)
Next k
Close #1
For k = 2 To 10
a = Mass(k)
Mass(0) = a
m = k
While a < Mass(m - 1)
Mass(m) = Mass(m - 1)
m = m - 1
Wend
Mass(m) = a
Next k
Open "e:\test_out.txt" For Output As #1
For k = 1 To 10
s = Mass(k)
Print #1, s
Next k
Close #1
End Sub
B.34.2.
Sub AA()
Dim Mass(1 To 11) As Integer
Dim k As Integer
Dim m As Integer
Dim s As String
Dim a As Integer
Open "e:\test_in.txt" For Input As #1
For k = 1 To 10
Input #1, Mass(k)
Next k
Close #1
For k = 9 To 1 Step -1
a = Mass(k)
Mass(11) = a
m = k
While a < Mass(m + 1)
Mass(m) = Mass(m + 1)
m = m + 1
Wend
Mass(m) = a
Next k
Open "e:\test_out.txt" For Output As #1
For k = 1 To 10
s = Mass(k)
Print #1, s
Next k
Close #1
End Sub
B.34.3.
Sub AA()
Dim Mass(1 To 10) As Integer
Dim k As Integer
Dim m As Integer
Dim s As String
Dim a As Integer
Open "e:\test_in.txt" For Input As #1
For k = 1 To 10
Input #1, Mass(k)
Next k
Close #1
For k = 10 To 2 Step -1
For m = 2 To k
If Mass(m - 1) > Mass(m) Then
a = Mass(m - 1)
Mass(m - 1) = Mass(m)
Mass(m) = a
End If
Next m
Next k
Open "e:\test_out.txt" For Output As #1
For k = 1 To 10
s = Mass(k)
Print #1, s
Next k
Close #1
End Sub
B.34.4.
Sub AA()
Dim Mass(1 To 10) As Integer
Dim k As Integer
Dim m As Integer
Dim s As String
Dim a As Integer
Open "e:\test_in.txt" For Input As #1
For k = 1 To 10
Input #1, Mass(k)
Next k
Close #1
For k = 1 To 9
For m = 9 To k Step -1
If Mass(m + 1) < Mass(m) Then
a = Mass(m + 1)
Mass(m + 1) = Mass(m)
Mass(m) = a
End If
Next m
Next k
Open "e:\test_out.txt" For Output As #1
For k = 1 To 10
s = Mass(k)
Print #1, s
Next k
Close #1
End Sub
B.34.5.
Sub AA()
Dim Mass(1 To 10) As Integer
Dim k As Integer
Dim m As Integer
Dim s As String
Dim a As Integer
Open "e:\test_in.txt" For Input As #1
For k = 1 To 10
Input #1, Mass(k)
Next k
Close #1
For k = 1 To 9
For m = 9 To k Step -1
If Mass(m + 1) > Mass(m) Then
a = Mass(m + 1)
Mass(m + 1) = Mass(m)
Mass(m) = a
End If
Next m
Next k
Open "e:\test_out.txt" For Output As #1
For k = 1 To 10
s = Mass(k)
Print #1, s
Next k
Close #1
End Sub
B.34.6.
Sub AA()
Dim Mass(1 To 10) As Integer
Dim k As Integer
Dim m As Integer
Dim s As String
Dim a As Integer
Open "e:\test_in.txt" For Input As #1
For k = 1 To 10
Input #1, Mass(k)
Next k
Close #1
For k = 10 To 2 Step -1
For m = 2 To k
If Mass(m - 1) < Mass(m) Then
a = Mass(m - 1)
Mass(m - 1) = Mass(m)
Mass(m) = a
End If
Next m
Next k
Open "e:\test_out.txt" For Output As #1
For k = 1 To 10
s = Mass(k)
Print #1, s
Next k
Close #1
End Sub
B.34.7.
Sub AA()
Dim Mass(1 To 10) As Integer
Dim k As Integer
Dim Left As Integer
Dim Right As Integer
Dim Pr As Boolean
Dim s As String
Dim a As Integer
Open "e:\test_in.txt" For Input As #1
For k = 1 To 10
Input #1, Mass(k)
Next k
Close #1
Pr = True
Left = 1
Right = 10
While Pr
Pr = False
For k = Left + 1 To Right
If Mass(k - 1) > Mass(k) Then
a = Mass(k - 1)
Mass(k - 1) = Mass(k)
Mass(k) = a
Pr = True
End If
Next k
For k = Right - 1 To Left Step -1
If Mass(k + 1) < Mass(k) Then
a = Mass(k + 1)
Mass(k + 1) = Mass(k)
Mass(k) = a
Pr = True
End If
Next k
Left = Left + 1
Right = Right - 1
Wend
Open "e:\test_out.txt" For Output As #1
For k = 1 To 10
s = Mass(k)
Print #1, s
Next k
Close #1
End Sub
B.34.8.
Sub AA()
Dim Mass(1 To 10) As Integer
Dim k As Integer
Dim Left As Integer
Dim Right As Integer
Dim Pr As Boolean
Dim s As String
Dim a As Integer
Open "e:\test_in.txt" For Input As #1
For k = 1 To 10
Input #1, Mass(k)
Next k
Close #1
Pr = True
Left = 1
Right = 10
While Pr
Pr = False
For k = Left + 1 To Right
If Mass(k - 1) < Mass(k) Then
a = Mass(k - 1)
Mass(k - 1) = Mass(k)
Mass(k) = a
Pr = True
End If
Next k
For k = Right - 1 To Left Step -1
If Mass(k + 1) > Mass(k) Then
a = Mass(k + 1)
Mass(k + 1) = Mass(k)
Mass(k) = a
Pr = True
End If
Next k
Left = Left + 1
Right = Right - 1
Wend
Open "e:\test_out.txt" For Output As #1
For k = 1 To 10
s = Mass(k)
Print #1, s
Next k
Close #1
End Sub
|