# 急求VB答案。。谢谢！！

xie0307 2010-04-21 10:00:48

...全文
102 11 打赏 收藏 转发到动态 举报

11 条回复

dl20070302 2010-04-29
• 打赏
• 举报

xie0307 2010-04-27
• 打赏
• 举报

myy168 2010-04-27
• 打赏
• 举报

chinaboyzyq 2010-04-25
• 打赏
• 举报

Private Sub Command1_Click()
Dim n As Integer, i As Integer
Dim tmp1 As Integer, tmp2 As Integer
Dim maxNum As Integer, avgNum As Single
n = Val(InputBox("请输入个数"))
For i = 1 To n
tmp1 = Int(Rnd * 100) + 10
Print tmp1;
If maxNum < tmp1 Then maxNum = tmp1
tmp2 = tmp2 + tmp1
Next
avgNum = tmp2 / n
Print: Print maxNum; avgNum

End Sub

threenewbee 2010-04-24
• 打赏
• 举报

Private Sub Command1_Click()
Dim n As Long
Dim na() As Long
Dim max As Long
Dim avg As Double
If n = 0 Then Exit Sub
ReDim na(1 To n)
Randomize
For i = 1 To n
na(i) = Int(Rnd * 90) + 10
If na(i) > max Then max = na(i)
avg = avg + na(i)
Next
avg = avg / n
For i = 1 To n
Print na(i);
Next
MsgBox "max is " & max & vbCrLf & "avg is " & avg
End Sub

• 打赏
• 举报

xie0307 2010-04-22
• 打赏
• 举报

i1u0i1u0 2010-04-22
• 打赏
• 举报

• 打赏
• 举报

chinaboyzyq 2010-04-22
• 打赏
• 举报

threenewbee 2010-04-22
• 打赏
• 举报

LZ自己已经把思路说完了。

1,452

• 近7日
• 近30日
• 至今