vb
2016-03-31 17:42
211 查看
打开vb后点击commandbutton拖入适当位置点击上方工具按钮在选择选项打开其中的编辑器格式将字体设置为24点击commandbutton后输入如下编码
Private Sub Command1_Click()
Cls
Dim x(15) As Integer, n As Integer
n = 1
While n <= 15
x(n) = Int(Rnd * 1000)
n = n + 1
Wend
Dim swap As Integer, m As Integer
m = 1
While m <= 14
n = 1
While n <= 15 - m
If x(n) < (n + 1) Then
swap = x(n)
x(n + 1) = swap
End If
n = n + 1
Wend
m = m + 1
Wend
n = 1
While n <= 15
Print x(n)
n = n + 1
Wend
End Sub
Private Sub Command1_Click()
Cls
Dim x(15) As Integer, n As Integer
n = 1
While n <= 15
x(n) = Int(Rnd * 1000)
n = n + 1
Wend
Dim swap As Integer, m As Integer
m = 1
While m <= 14
n = 1
While n <= 15 - m
If x(n) < (n + 1) Then
swap = x(n)
x(n + 1) = swap
End If
n = n + 1
Wend
m = m + 1
Wend
n = 1
While n <= 15
Print x(n)
n = n + 1
Wend
End Sub