1樓:匿名使用者
private sub command1_click()on error resume next
dim a(5) as integer
randomize
'int((upperbound - lowerbound + 1) * rnd + lowerbound)
for i = 0 to 3
b = ""
c = 0
for j = 1 to 5
a(j) = int((100 - 10 + 1) * rnd + 10)
b = b & " " & a(j)
next
c = a(1)
if c < a(2) then c = a(2)if c < a(3) then c = a(3)if c < a(4) then c = a(4)if c < a(5) then c = a(5)print b & " 最大數為:" & cnext
end sub
2樓:匿名使用者
option explicit
private sub command1_click()randomize timer
dim i as byte, max as byte, min as byte, irnd as byte
min = 255
for i = 1 to 20
irnd = 10 + int(rnd * 91)if irnd > max then max = irndif irnd < min then min = irndprint format(irnd, "@@@ ");
if i mod 5 = 0 then printnext
print "max num:"; max; " min num:"; min
end sub
3樓:excel開發
private sub form_click()dim i, j, a(20) as integerrandomize
a(0) = int(rnd() * 91 + 10)j = a(0)
print a(0); " ";
for i = 1 to 19
a(i) = int(rnd() * 91 + 10)if i mod 5 = 0 then printprint a(i); " ";
if j < a(i) then j = a(i)next i
print "最大值="; j
end sub
4樓:匿名使用者
private sub command1_click()dim a(21) as integer, s as stringdim i as integer, m as integerrandomize
for i = 1 to 20
a(i) = int(90 * rnd + 10)s = s & " " & a(i)
if i mod 5 = 0 then
s = s & chr(13)
end if
next i
m = a(1)
for i = 2 to 20
if m < a(i) then m = a(i)next i
print "隨機數為:" & chr(13) & sprint "最大數:" & m
end sub
vb程式設計:產生20個10至100間的隨機整數存入一維陣列a中,每行5個元素輸出;定義一個4行5列的二維陣列
5樓:匿名使用者
private sub command1_click()dim a(20) as integer, b(4, 5) as integer
randomize
for i = 1 to 20
a(i) = int(rnd * 91) + 10print a(i);
if i mod 5 = 0 then printnext
for i = 1 to 4
for j = 1 to 5
b(i, j) = a(j + (i - 1) * 5)print b(i, j);
next
next
end sub
6樓:匿名使用者
private sub form_load()dim a(1 to 20) as integerdim b(1 to 4, 1 to 5) as integerdim j, i as integer
j = 1
for i = 1 to 20
randomize
a(i) = int(rnd() * 90) + 10next i
for i = 1 to 20
k = i mod 5
if k = 0 then k = 5
b(j, k) = a(i)
if i mod 5 = 0 then j = j + 1next i
print "a:"
for i = 1 to 20
print a(i),
if i mod 5 = 0 then print chr(13)next i
print "b:"
for i = 1 to 4
for j = 1 to 5
print b(i, j),
next j
next i
end sub
原創喲,臭美一下
7樓:匿名使用者
dim i as long,a(1 to 20) as longfor i=1 to 20
a(i)=cint(int((100- 10+ 1) * rnd() + 10))
next i
vb產生30個0~1000的隨機整數,放入一個陣列中,輸出最大值
8樓:兄弟連教育北京總校
'實現**如下
private sub form_click()me.cls
dim n(1 to 30) as integerdim i%,nmax%
dim str as string
'產生30個0-1000的隨機數並寫入陣列randomize
for i = 1 to 30
n(i) = int((1000 - 0 + 1) * rnd + 0)
str = str & n(i) & " "
if i mod 10=0 then str=str & vbcrlf
next i
'找最大值
nmax=n(1)
for i = 1 to 30
if n(i)>nmax then nmax=n(i)next i
print str '窗體顯示隨機數
print "最大值:" & nmax
end sub
vb編寫程式,隨機產生20個10到100間的整數 輸出這些數 並求這批數的最大值及其位置
9樓:聽不清啊
private sub command1_click()dim a(20) as integer
randomize
max = 0: j = 0
for i = 1 to 20
a(i) = int(91 * rnd) + 10print a(i);
if max < a(i) then max = a(i): j = i
next i
print "最大值="; max, "出現在第版權"; j; "個"
end sub
用vb程式設計實現隨機產生100到999之間的隨機數並
vba程式設計實現不重複隨機數輸出。vba裡的隨機函式是rnd,在工作表中隨機函式是rand,一字e68a8462616964757a686964616f31333363393566之差,可要記好了。rnd取值範圍是 0,1 意思是0和1之間的一個隨機數,包含0,但不包含1。1 用法 語法 rnd ...
vb6中,當程式執行後,隨機產生數,並且判斷奇數偶數。程式怎麼寫
新增窗體form1,文字框text1,按鈕command1,command2,然後新增如下 private sub form load command1.caption 產生隨機數 command2.caption 判斷 text1.locked false a false end sub priv...
求c定義大小為10的整型陣列用隨機產生的數
你是要控制檯還是windows窗體程式?這個是控制檯的,你要是要windows窗體版的改下最後權 的就是int a new int 10 random r new random for int i 0 i a.length i a i r.next array.sort a array.revers...