利用一维数组,统计一个班10名学生成绩0~59,60~69,70~79,80~89,90~100各分数段的人数。要求:

1个回答

  • Option Base 1

    Private Sub Form_Click()

    Dim stu(10), num(0 To 10) As Integer

    Print "学生成绩为:"

    For i = 1 To 10

    stu(i) = Int(Rnd * 100)

    Print stu(i);

    n = n + 1

    If n Mod 5 = 0 Then Print

    x = stu(i)

    Select Case x

    Case 100 To 100

    num(x 10) = num(x 10) + 1:

    Case 90 To 99

    num(x 10) = num(x 10) + 1

    Case 80 To 89

    num(x 10) = num(x 10) + 1

    Case 70 To 79

    num(x 10) = num(x 10) + 1

    Case 60 To 69

    num(x 10) = num(x 10) + 1

    Case Else

    num(5) = num(5) + 1

    End Select

    Next i

    Print "统计"

    For j = 5 To 10

    Print j * 10; "之间分数的人数个数" & num(j)

    Next j

    Max = stu(1): Min = stu(1)

    For i = 1 To 10

    If stu(i) > Max Then Max = stu(i)

    If stu(i) < Min Then Min = stu(i)

    Next i

    Print "最小分数为:"; Min

    Print "最大分数为:"; Max

    End Su