3个回答
展开全部
Private Sub Form_Load()
Dim a(10), i, x, j As Integer
Dim y As String
For i = 0 To 9
Randomize
a(i) = Int(Rnd(1) * 101)
x = x + a(i)
Next i
Print "元素和=" & x
Print "平均值=" & x / 10
For i = 0 To 9
If a(i) > (x / 10) Then j = j + 1: y = y & CStr(a(i)) & " "
Next i
Print "大于平均值的元素个数=" & j
Print "大于平均值的元素:" & y
Me.Refresh
End Sub
Dim a(10), i, x, j As Integer
Dim y As String
For i = 0 To 9
Randomize
a(i) = Int(Rnd(1) * 101)
x = x + a(i)
Next i
Print "元素和=" & x
Print "平均值=" & x / 10
For i = 0 To 9
If a(i) > (x / 10) Then j = j + 1: y = y & CStr(a(i)) & " "
Next i
Print "大于平均值的元素个数=" & j
Print "大于平均值的元素:" & y
Me.Refresh
End Sub
展开全部
Private Sub Command3_Click()
'用VB编程:随机产生10个0~100之间的随机整数,存放在一个数组中,
'然后求个元素和、平均值,统计
'大于平均值的元素个数并把它们显示出来?
Dim MyValue(100) As Integer
Dim i As Integer
Dim n As Integer
Dim sum As Double
Dim ave As Double
n = 100
sum = 0
ave = 0
For i = 1 To n
MyValue(i) = Int(100 * Rnd) ' 生成 0 到 6 之间的随机数值。
sum = sum + MyValue(i)
Next i
ave = sum / n
For i = 1 To n
If MyValue(i) > ave Then
Print MyValue(i)
End If
Next i
End Sub
'用VB编程:随机产生10个0~100之间的随机整数,存放在一个数组中,
'然后求个元素和、平均值,统计
'大于平均值的元素个数并把它们显示出来?
Dim MyValue(100) As Integer
Dim i As Integer
Dim n As Integer
Dim sum As Double
Dim ave As Double
n = 100
sum = 0
ave = 0
For i = 1 To n
MyValue(i) = Int(100 * Rnd) ' 生成 0 到 6 之间的随机数值。
sum = sum + MyValue(i)
Next i
ave = sum / n
For i = 1 To n
If MyValue(i) > ave Then
Print MyValue(i)
End If
Next i
End Sub
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
dim A(9) as integer,i as integer,cnt as integer,sum as integer,avg as double
sum=0
for i =0 to 9
A(i)=int(rnd*100)
sum=sum+A(i)
next i
avg=sum/10
cnt=0
for i=0 to 9
if A(i)>avg then
print A(i)
cnt=cnt+1
endif
next i
print cnt
sum=0
for i =0 to 9
A(i)=int(rnd*100)
sum=sum+A(i)
next i
avg=sum/10
cnt=0
for i=0 to 9
if A(i)>avg then
print A(i)
cnt=cnt+1
endif
next i
print cnt
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询