VB随机产生30个[10,99]的自然数.随机产生30个[10,99]的自然数.(1)每行10个输出这30个随机数;(2)输出去掉最大、最小值后的平均值.要代码
VB随机产生30个[10,99]的自然数.
随机产生30个[10,99]的自然数.
(1)每行10个输出这30个随机数;
(2)输出去掉最大、最小值后的平均值.
要代码
Dim a(1 To 30) As Integer
Dim b(0 To 2, 1 To 10) As Integer
Dim bmax(0 To 2) As Integer
Dim bmin(0 To 2) As Integer
Dim sum(0 To 2) As Long
Dim p As String
For i = 1 To 30
a(i) = Int(10 + Rnd * (99 - 10 + 1))
Next
For i = 0 To 2
bmin(i) = 99
For j = 1 To 10
p = p & " " & Str(a(i * 10 + j))
b(i, j) = a(i * 10 + j)
If b(i, j) >= bmax(i) Then bmax(i) = b(i, j)
If b(i, j) sum(i) = sum(i) + b(i, j)
Next
Print p
p = ""
Next
For i = 0 To 2
Print "第" & i + 1 & "行去掉最大和最小之后平均值为:" & Format((sum(i) - bmax(i) - bmin(i)) / 8, "##.0##")
Next
Option Base 1Dim a(30) As IntegerPrivate Sub Command1_Click()Dim max As Integer '储存最大值Dim min As Integer '储存最小值Dim sum As Integer '储存总分Dim n As Integer '储存分数Dim aver As Integer '平均...