VB编一函数,实现产生任意两个正整数之间的随机整数,并调用它求出10组两个随机整数之和并输出。

2026年09月19日 19:30
有2个网友回答
网友(1):

Private Sub Command1_Click()
Dim i As Integer, n As Integer
For i = 1 To 10
n = n + a(Int(Rnd * 20), Int(Rnd * 30))
Next
Print n

End Sub

Function a(ByVal x As Integer, ByVal y As Integer) As Integer
Dim t As Integer
If x > y Then t = x: x = y: y = t
a = x + Int((y - x + 1) * Rnd)

End Function

网友(2):

x^3