vb程序题,随机产生6个100~200的整数,然后按值从大到...
发布网友
发布时间:2023-11-06 15:00
我来回答
共1个回答
热心网友
时间:2024-06-16 16:57
Private Sub Command1_Click()
Dim a(0 To 5) As Integer
Cls
Randomize
For i = 0 To 5
a(i) = Int(100 * Rnd)+100
For j = 0 To i - 1
If a(i) = a(j) Then i = i - 1: Exit For
Next
Next
Print "生成的数为:"
For i = 0 To 5
Print a(i);
Next
For i = 1 To 5
For j = 0 To 5 - i
If a(j) < a(j + 1) Then t = a(j): a(j) = a(j + 1): a(j + 1) = t
Next
Next
Print
Print "排序之后为:"
For i = 0 To 5
Print a(i);
Next
End Sub