VB随机产生30个[10,99]的自然数.

2个回答

  • Option Base 1

    Dim a(30) As Integer

    Private Sub Command1_Click()

    Dim max As Integer '储存最大值

    Dim min As Integer '储存最小值

    Dim sum As Integer '储存总分

    Dim n As Integer '储存分数

    Dim aver As Integer '平均数

    '产生随机数3行10列输出

    For i = 1 To 30

    Randomize

    a(i) = Int(Rnd * 90) + 10

    Print a(i);

    s = s + 1

    If s = 10 Then

    Print vbCrLf

    s = 0

    End If

    Next i

    max = a(1)

    min = a(1)

    sum = a(1)

    For i = 2 To 30

    sum = sum + a(i)

    If a(i) > max Then

    max = a(i)

    End If

    If a(i) < min Then

    min = a(i)

    End If

    Next i

    sum = sum - max - min

    aver = sum / 28

    Print max,min,sum

    Print "输出去掉最大、最小值后的平均值是:" & aver

    End Su