Public Class 例5_9

    Private Sub 例5_9_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim a(9) As Integer
        Dim i As Integer, j As Integer, t As Integer
        Randomize()
        Console.WriteLine("原始数据如下：")
        For i = 0 To 9
            a(i) = Int(200 * Rnd()) + 100      '产生10个随机整数，区间[100, 299]
            Console.Write(a(i) & vbTab)
        Next i
        For i = 0 To 8
            For j = i + 1 To 9
                If a(i) < a(j) Then
                    t = a(i) : a(i) = a(j) : a(j) = t     '交换a(i)与a(j)
                End If
            Next
        Next
        Console.WriteLine()
        Console.WriteLine("按从大到小的顺序排列输出：")
        For i = 0 To 9
            Console.Write(a(i) & vbTab)
        Next
        Console.WriteLine()
    End Sub
End Class