1樓:匿名使用者
dim i as integer, a(100) as integer, sum as long
private sub command1_click()
me.cls
print "100個隨機數:"
randomize
for i = 1 to 100
a(i) = int((rnd() * (255 - 100 + 1)) + 100)
sum = sum + a(i)
print a(i);
if i mod 10 = 0 then print
next i
end sub
private sub command2_click()
max = a(1): min = a(1): maxi = 1: mini = 1
for i = 2 to 100
if a(i) > max then max = a(i): maxi = i
if a(i) < min then min = a(i): mini = i
next i
print "第" & maxi & "個元素最大=" & max & " " & "第" & mini & "個元素最小=" & min
print "平均值:" & sum / 100
end sub
2樓:
不給分,沒人理~~飄過。
用vb編寫利用隨機函式產生10 99之間(包括10和
dim n m,a 19 max max 0 for n 0 to 19 a n int rnd 90 10 生成20個10 99的隨機數 next n for n 0 to 18 for m n 1 to 19 if a n a m then swap a n a m 排序從小到大end if n...
VB標籤裡隨機產生數
private sub cmdrnd click labrnd.caption int rnd 100000 100 mod 100000 end sub labrnd 那個標籤 cmdrnd 那個命令按鈕 dim i as integer const n 5 dim x n as integer ...
VB 產生隨機數用什麼語句
補充 private sub command1 click dim i j x randomize for i 1 to 5 for j 1 to 10 x int 10 rnd 1 print x if x 8 then exit for nextprint nextend sub int upp...