Public Class 例5_4

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim i As Integer, A(10) As Single
        Dim max As Single, min As Single
        Dim sum As Single, average As Single, count As Integer
        A(1) = InputBox("请输入第1个数")
        TextBox1.Text = A(1)        '将第1个数据输出到文本框TextBox1
        sum = A(1)                      '将第1个数存入累加和
        max = A(1) : min = A(1)     '将第1个数作为当前的最大数和最小数
        For i = 2 To 10             '将第2～10个数据输出到文本框TextBox1
            A(i) = InputBox("请输入第" & Str(i) & "个数")
            TextBox1.Text = TextBox1.Text & "  " & A(i)
            sum = sum + A(i)                    '数据累加
            If A(i) > max Then max = A(i) '查找最大数
            If A(i) < min Then min = A(i) '查找最小数
        Next i
        average = sum / 10
        TextBox3.Text = min                 '输出最小数
        TextBox4.Text = max                 '输出最大数
        TextBox5.Text = average             '输出平均值
        For i = 1 To 10
            '将高于平均值的数据输出到文本框TextBox2
            If A(i) > average Then
                TextBox2.Text = TextBox2.Text & A(i) & "  "
                count = count + 1               '对高于平均值的数据进行计数
            End If
        Next i
        TextBox6.Text = count               '输出高于平均值的数据个数

    End Sub
End Class