1樓:匿名使用者
呵呵,借鑑一下樓上的。
加了一個**,為了不讓隨機出來的數重複。
private sub command1_click()dim s(1 to 8, 1 to 8) as integerdim stra(1 to 900) as integerdim maxs as integer, l as integer, r as integer
dim ss as string
j = 1
jjj = 900
for i = 100 to 999
stra(j) = i
j = j + 1
next i
randomize
for j = 1 to 8
for i = 1 to 8
jjj = jjj - 1
jj = int(jjj * rnd + 1)s(j, i) = stra(jj)
for iii = jj to jjj - 1stra(iii) = stra(iii + 1)next iii
ss = ss & s(j, i) & " | "
if s(j, i) > maxs thenmaxs = s(j, i)
l = j: r = i
end if
next
ss = ss & vbcrlf
next
me.show
print "最大數:" & maxs, "行" & l, "列" & r
print ss
end sub
2樓:匿名使用者
n=rnd*1000
for a=100 to n
for b=100 to n
3樓:棘棘芽
private s(1 to 7, 1 to 7) as integer
private sub form_load()dim maxs as integer, l as integer, r as integer
dim ss as string
randomize
for j = 1 to 7
for i = 1 to 7
s(j, i) = int(rnd * 900) + 100ss = ss & s(j, i) & " | "
if s(j, i) > maxs thenmaxs = s(j, i)
l = j: r = i
end if
next
ss = ss & vbcrlf
next
me.show
print "最大數:" & maxs, "行" & l, "列" & r
print ss
end sub
vb用氣泡排序法實現對陣列中含有元素隨機
這個要動態演示排序過程麼?還是直接顯示排序的結果? private sub command1 click dim a 1 to 10 i j,s as integerrandomize for i 1 to 10 隨機10個產生1 100的整數 a i int rnd 100 1next i for...
VB陣列操作,VB怎麼宣告陣列
能你的例子 希望對你有幫助 dim a 3 as integer dim i as integer a 0 1 a 1 2 a 2 3 a 3 4 for i o to 3 text1.text text1.text a i next i vb怎麼宣告陣列 如果有規律就可以用for next 來賦值...
vb定義陣列
阿豪呦 有兩種方法定義陣列 1.知道陣列的元素個數,那麼直接定義 dim a 9 as integer 2.暫時不知道元素個數,或者該陣列應用在多個地方,那麼如下定義 dim a as integer 在使用的時候,再重定義一下就可以了 redim a 9 dim private public 陣列...