pggw.net
当前位置:首页 >> vB 利用随机函数产生10个1~100之间的随机数,显示出最大值最小值,平均值 >>

vB 利用随机函数产生10个1~100之间的随机数,显示出最大值最小值,平均值

Private Sub Form_Click() Dim a(9) As Integer, max As Integer, min As Integer, arg As Single, i As Integer Randomize For i = 0 To 9 a(i) = Int(Rnd * 100) + 1 arg = arg + a(i) If i = 0 Or a(i) > max Then max = a(i) If i = 0 Or a(i) < min Then min = a(i) Print

Private Sub Form_click()Dim a(9)Dim m(), n() 'm()为偶数集, n()为奇数集Dim i, p, qDim sumDim avg1, avg2 'avg1为奇数平均数, avg2为偶数平均数Dim max, minFor i = 0 To 9 Randomize a(i) = Int(Rnd() * 99 + 1) If a(i) Mod 2 = 0 Then '判

程序基本正确.随机生成十个数字(1-100之间的整数)应该是:1+Int(Rnd * 100)

Private Sub Command1_Click() Dim i%, j%, max%, min%, s% For i = 1 To 10 j = Int(Rnd * 100 + 1) If i = 1 Then min = j If j > max Then max = j If j < min Then min = j s = s + j Print j; Next Print Print "最大值,最小值,平均数分别为:"; max; min; s / 10 End Sub

帮你写好了,这个是工程文件,下载下来就可以了.以下是源码:Private Sub Command1_Click()Dim A(10) As Double, L As Integer, B As Double, C As Double, D As DoubleRandomize '根据时间初始化随机数A(0) = (Rnd

Private Sub Command1_Click() Dim a(10) As Integer Randomize Max = 1 For i = 1 To 10 a(i) = 1 + Int(Rnd * 100) Print a(i); If a(i) > a(Max) Then Max = i Next i Print Print "a("; Max; ")="; a(Max)End Sub

option base 1 private sub command1_click() dim arr(20) as integer, max as integer, min as integer dim s as single cls max = 50 min = 100 print "产生的随机数为:" for i = lbound(arr) to ubound(arr) randomize arr(i) = int(rnd * 51) + 50 if arr(i) >

Private Sub Command1_Click() Randomize Dim a(10) As Integer, imas as integer, imin as integer, Average as integer imax = 49 imin = 101 Average=0 For i = 0 To 9 a(i) = Int(Rnd * 51) + 50 Average=Average+a(i) If imax < a(i) Then imax = a(i) If

Private Sub Command1_Click() Dim i, max, min, s As Integer max = 0 min = 100 s = 0 Dim a(30) As Integer Text1.Text = "" Text2.Text = "" Text3.Text = "" Randomize Now For i = 1 To 30 a(i) = Int((100 - 50 + 1) * Rnd + 50) If max If min > a(i)

相关文档
网站首页 | 网站地图
All rights reserved Powered by www.pggw.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com