1樓:匿名使用者
private sub command1_click()
dim max as integer, maxi as integer, min as integer, mini as integer
dim a(10) as integer
randomize
for i = 1 to 10
a(i) = int(((99 - 10 + 1) * rnd) + 10)
print a(i);
next i
max = a(1): maxi = 1: min = a(1): mini = 1
for i = 2 to 10
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
end sub
2樓:匿名使用者
來個簡單的(附圖):
dim a%(9)
private sub form_click()randomize
print "原數列"
for i = 0 to 9
a(i) = int(rnd * 11 + 10)print a(i);
next
max = a(0): min = a(0)for i = 1 to 9
if max < a(i) then max = a(i)if min > a(i) then min = a(i)next
print "最大值:"; max; " 最小值:"; minend sub
vb隨機10個兩位整數,找出其中最大,最小值
3樓:聽不清啊
private sub command1_click()randomize
max = 0
min = 100
print "10個隨機整數為:"
for i = 1 to 10
x = int(rnd * 90) + 10print x;
if x > max then max = xif x < min then min = xnext i
print "最大值:"; max
print "最小值:"; min
end sub
vb題,用隨機函式生成包含10個兩位整數的一維陣列,求這10個數的最大值,最小值以及平均值。
4樓:匿名使用者
執行結果:
生成的陣列為
73 58 62 36 37 79 11 78 83 73排序後的陣列為
83 79 78 73 73 62 58 37 36 11該陣列元素各個元素的和是 590 最大元素是 83 最小元素是 11
vb生成10個兩位隨機數,求出其中最大值、最小值、平均值
5樓:寒信
dim a(9) as integer,i as integer ,max as integer,min as integer , s as integer
for i=0 to 9
randomize
a(i)=rnd* 1)*90+10
if i=0 then or a(i)>max then max=a(i)
if i=0 or a(i) print a(i); next i print print "最大數為"& max & ",最小數為" & min & ",平均值為" & (s/10) vb程式設計「生成10個二位數,求出其中的最大值、最小值、平均值,並指出最大最小值是第幾個隨機數」 6樓:匿名使用者 private sub command1_click()dim max, min, pj, a(1 to 10)pj = 0 max = 0 min = 100 randomize print "產生的10個數為:"; for i = 1 to 10 a(i) = int(rnd(1) * 90 + 10)if a(i) > max then max = a(i)if a(i) < min then min = a(i)pj = pj + 0.1 * a(i) print a(i); next i print print "最大數為:", max print "最小數為:", min print "平均數為:", pj end sub 7樓:匿名使用者 private sub command1_click()dim n(1 to 10), max, min, i as integer dim q, w, s as integers = 0 for i = 1 to 10 randomize n(i) = int(rnd * 90 + 10)print n(i) next i max = n(1) min = n(1) for i = 1 to 10 if n(i) > max then max = n(i) q = i end if if n(i) < min then min = n(i) w = i end if s = s + n(i) next i print "最大為第" & q & "位,為:" & max; " 最小為第" & w & "位,為:" & min print "平均數為:"; s / 10end sub 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設計 隨機產生10個100到200之間的數,求出最大值與最小值
20 9樓:刺友互 1、首先需要啟動vb6.0,新建一個標準exe工程。 2、開啟vb6.0之後,在窗體上繪製一個命令按鈕。 3、接下來需要雙擊命令按鈕進入**視窗。 4、接下來開始編輯按鈕的單擊事件。 5、最後就可以按f5執行測試。求出最大值與最小值。 10樓:指尖遊戲 dim a(9) as integer '定義一個整數變數陣列,大小為10 for i = 0 to 9 randomize ' a(i) = int(rnd * 100 + 100) '隨機生成10個數字 next dim b as integer '定義一個臨時變數for i = 0 to 8 for j = i + 1 to 9 if a(j) < a(i) then '將9個數按照大小排序 b = a(j) a(j) = a(i) a(i) = b end if next next 最大值為a(9),最小值為a(0) 11樓:瘋狂小鳥 如圖所示,望採納。。。。 12樓: private sub form_load()dim n, a, max as integern = 1 max = int(rnd * 101 + 100)print max; don = n + 1 a = int(rnd * 101 + 100)print a; if a > max then max = aloop while n < 10 print print max end sub 應當可以 13樓:匿名使用者 如圖所示,望~~。。。。 j的起始值應該從2開始 include include include using namespace std void prime int a 10 void main if t 0 break cout cout n 其中的素數有 prime a void prime int a 10 if t... private sub button1 click byval sender as system.object,byval e as system.eventargs handles button1.click dim m 100 as integerdim n 128 as integerrand... 被計算機2級考試折磨的可憐娃兒 private sub form load dim mr 1 to 50 as byte,x as byte dim i as long,j as long,t as long,b as boolean dim so as string 產生50個隨機二位整數 ran...C 用隨機函式產生互不相同的兩位整數存放到一維陣列中,並輸出其中的素數
VB關於輸出!隨機產生ASCII字元分別求09等
VB編寫,產生隨機二位整數,存入陣列中,計算總和,將陣列元素按升序排序,並按每行列印輸出