1樓:匿名使用者
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
next m
next n
for n=1 to 19
if a(n)-a(n-1)>max thenmax=a(n)-a(n-1) ’計算相差最大值,賦值給maxend if
next n
2樓:幸福答案
'只須在窗體內忝加一個command即可
private sub command1_click()clsdim a(1 to 20), b(1 to 19)randomize
print "隨機生成的這組數是:"
for i = 1 to 20
a(i) = int(rnd * 90) + 10print a(i);
if i = 10 then print
next
print "這組數按從大到小的順序排列每10人一行輸出如下:"
for i = 1 to 20
for j = i + 1 to 20
if a(i) < a(j) then
t = a(i): a(i) = a(j): a(j) = tend if
next
print a(i);
if i mod 10 = 0 then printnext
for i = 1 to 19
b(i) = a(i) - a(i + 1)next
x = b(1)
for i = 1 to 19
if x < b(i) then x = b(i)next
print "相鄰兩個數的最大差值是:" & xend sub
3樓:
dim i%, j%, a%(20), max%max = 0
randomize
for i = 1 to 20
a(i) = int((rnd * 90) + 10) '生成20個10-99的隨機數
print a(i);
next i
for i = 1 to 19
for j = i + 1 to 20
if a(i) > a(j) then
t = a(i): a(i) = a(j): a(j) = t '排序從小到大
end if
next j
next i
for i = 1 to 20
print a(i);
next i
for i = 2 to 20
if a(i) - a(i - 1) > max thenmax = a(i) - a(i - 1) '計算相差最大值,賦值給max
end if
next i
print "max="; max
4樓:遠風的夢想家
option explicit
option base 1
dim a%(80), i%, k%, t%, b%(80)private sub command1_click()me.cls
dim j as integer
randomize
for i = 1 to 80
a(i) = int(rnd * 90) + 10next i
k = 0
t = 1
for i = 1 to 79
b(i) = abs(a(i + 1) - a(i))if b(i) > k then
k = b(i)
t = i
end if
next i
print "全部"
for i = 1 to 80
print a(i);
if i mod 10 = 0 then printnext i
print "最大差值:" & k & ",是" & a(t + 1) & "和" & a(t) & "之差"
end sub
5樓:不小心牛叉了
那你寫吧,我就不寫了
利用vb隨機函式產生20個10到99的隨機整數存入一維陣列a,找出其中所有奇數並統
6樓:匿名使用者
如果是病毒感染導致的發熱,是容易反**熱的,一般病程在一週左右。還是建議檢查血常規,瞭解感染情況,明確診斷,再對症用藥。注意多給孩子喝水。
其次,還有一種情況,就是如果有血象的升高,抗生素不能控制感染,也是有可能導致發熱的。所以還是建議先檢查血常規,瞭解感染的情況,對症用藥。
你好發燒是很多疾病都會有的症狀,一定要把引起發燒的病治好了,燒才能真正的退下來。如果還有咳嗽、流鼻涕等感冒症狀,需要用雙撲偽麻分散片、小兒氨酚黃那敏顆粒等感冒藥**。體溫在三十八點五度以上時,可用美林或泰諾林退燒**;體溫在三十八點五度以下時,或勤些用溫水擦浴以降溫,或用兵兵退熱貼敷額以降溫能起到退熱護腦的作用。
7樓:fm網路
dim a(20) as int
dim i as int
dim j as int
j=0for i=0 to 19
a(i)=rnd()*79+20
if a(i) mod 2=1 then
j=j+1
end if
next
print j
vb程式設計-利用隨機函式產生80個10~99之間的隨機整數 5
8樓:匿名使用者
option explicit
private sub command1_click()
dim a(80) as integer, b() as integer, nb as integer
dim i as integer, j as integer, t as integer
'隨機生成80個隨機數
text1.text = ""
randomize
for i = 1 to 80
a(i) = int(90 * rnd) + 10
text1.text = text1.text & a(i) & " "
'每顯示十個數字換行
if i mod 10 = 0 then text1.text = text1.text & chr(13) & chr(10)
next i
'查詢奇數併到新陣列中
for i = 1 to 80
if a(i) mod 2 = 1 then
nb = nb + 1
redim preserve b(nb)
b(nb) = a(i)
end if
next i
'對奇數排序
for i = 1 to nb - 1
for j = i + 1 to nb
if b(i) > b(j) then
t = b(i)
b(i) = b(j)
b(j) = t
end if
next j
next i
'輸出奇數到文字框
text2.text = ""
for i = 1 to nb
text2.text = text2.text & b(i) & " "
if i mod 10 = 0 then text2.text = text2.text & chr(13) & chr(10)
next i
'查詢輸出素數
text3.text = ""
t = 0
for i = 1 to 80
if sushu(a(i)) = true then
t = t + 1
text3.text = text3.text & a(i) & " "
if t mod 10 = 0 then text3.text = text3.text & chr(13) & chr(10)
end if
next i
end sub
private function sushu(n as integer) as boolean '判斷某數是否素數
dim i as integer, p as integer
p = int(sqr(n))
for i = 2 to p
if n mod i = 0 then exit for
next i
if i > p then sushu = true
end function
窗體上放text1,text2,text3,command1,文字框要設定換行和滾動條
9樓:guoxin愛記錄
dim a(1 to 80)
randomize
for i =1 to 80
a(i)=int(rnd*80)+10
print a(i)
next i
在vb中,如何編寫程式通過隨機函式產生10~99之間的隨機整數?
10樓:匿名使用者
vb 產生隨機數的公式(上界-下界+1)*rnd+下界你的題目就應該是(99-10+1)*rnd +10一般用rnd的時候還要在前面加一條 randomize 初始化隨機種 子
11樓:匿名使用者
randomize time '初始化
print int(rnd * 90) + 10 '產生隨機數,並輸出
12樓:匿名使用者
private sub form_click()randomize
for i = 10 to 99
n = int(rnd * i + 10)next
print nend sub
13樓:匿名使用者
dim tmp as byte randomize timer ' 隨機種子 tmp=int(rnd * 90+10) msgbox tmp ' 輸出隨機數
隨機函式產生100個10-99之間的隨機整數
14樓:百度文庫精選
內容來自使用者:範衛超10
利用隨機函式產生100個10-99之間的隨機整數,找出其中的奇數和素數,並將奇數按由小到大的順序排列。
private sub command1_click()dim a(1 to 100) as integer, b() as integer
show
redim b(100) as integerrandomize timer
print "隨機產生的資料是:"
for i = 1 to 100
a(i) = int(rnd * 90 + 10)print a(i); " ";
if i mod 10 = 0 then printnext i
print "找到的素數是:"
for i = 1 to 100
if fnprime(a(i)) thenprint a(i); " ";
c = c + 1
if c mod 10 = 0 then printend if
next i
print "找到的奇數是:"
for i = 1 to 100
if a(i) mod 2 = 1 thenk = k + 1
b(k) = a(i)
end if
next i
redim preserve b(k)
for i = 1 to k
print b(i); " ";
d = d + 1
if d mod 10 = 0 then printnext i
for i = 1 to k - 1
for j = i + 1 to k
if b(i) > b(j) then
t = b(i): b(i) = b(j): b(j) = tend if
next j
next i
print "排序結果:"
for j = 1 to k
print b(j);
g = g + 1
if g mod 10 = 0 then printnext j
end sub
private sub form_load()end sub
function fnprime(m as integer) as boolean
dim e as integer, f as booleanf = true
for e = 2 to m - 1
if m mod e = 0 then
vb利用隨機函式產生100 255(包括100和
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 s...
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...
VB編寫,產生隨機二位整數,存入陣列中,計算總和,將陣列元素按升序排序,並按每行列印輸出
火鍋兎 被計算機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個隨機二位整數...