設計程式vb隨機產生10到100之間(包括10和

時間 2021-08-30 10:29:00

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

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

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

print

for i = 1 to 4

for j = 1 to 5

b(i, j) = a(j + (i - 1) * 5)print b(i, j);

next

print

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

print

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

print "最大值="; max, "出現在第版權"; j; "個"

print

end sub

利用vb隨機函式產生10到99的隨機整數存入一維

如果是病毒感染導致的發熱,是容易反 熱的,一般病程在一週左右。還是建議檢查血常規,瞭解感染情況,明確診斷,再對症用藥。注意多給孩子喝水。其次,還有一種情況,就是如果有血象的升高,抗生素不能控制感染,也是有可能導致發熱的。所以還是建議先檢查血常規,瞭解感染的情況,對症用藥。你好發燒是很多疾病都會有的症...

怎麼用vb設計隨機產生100到200之間的數求出

刺友互 1 首先需要啟動vb6.0,新建一個標準exe工程。2 開啟vb6.0之後,在窗體上繪製一個命令按鈕。3 接下來需要雙擊命令按鈕進入 視窗。4 接下來開始編輯按鈕的單擊事件。5 最後就可以按f5執行測試。求出最大值與最小值。 指尖遊戲 dim a 9 as integer 定義一個整數變數陣...

“求1到10的階乘之和”用vb怎麼程式設計序

先寫一個求階乘的函式 private function factorial byval n as integer as long dim i as integer,l as longl 1 for i 1 to n l l i next factorial l end function 新增一個按鈕...