vb编程:随机产生10个0~100之间的数放到一个一维数组中,将10个数从小到大排序,在窗体上显示排序效果。
1个回答
展开全部
Option Explicit
Private Sub Form_Load()
Dim arr(1 To 10), i, j, tmp
Me.AutoRedraw = True
Randomize
For i = 1 To 10
arr(i) = Int(Rnd * 101)
Print arr(i);
Next i
Print
For i = 1 To 10
For j = i + 1 To 10
If arr(i) > arr(j) Then
tmp = arr(i)
arr(i) = arr(j)
arr(j) = tmp
End If
Next j
Next i
For i = 1 To 10
Print arr(i);
Next i
End Sub
Private Sub Form_Load()
Dim arr(1 To 10), i, j, tmp
Me.AutoRedraw = True
Randomize
For i = 1 To 10
arr(i) = Int(Rnd * 101)
Print arr(i);
Next i
For i = 1 To 10
For j = i + 1 To 10
If arr(i) > arr(j) Then
tmp = arr(i)
arr(i) = arr(j)
arr(j) = tmp
End If
Next j
Next i
For i = 1 To 10
Print arr(i);
Next i
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询