1樓:匿名使用者
private sub command1_click()randomize
dim a(14) as integer
for i = 0 to 14
a(i) = 2
next i
label1.caption = ""
for i = 0 to 14
doa(i) = int(rnd * 81 + 10)loop until a(i) mod 2 = 1label1.caption = label1.caption & a(i) & " "
next i
end sub
2樓:匿名使用者
寫成函式, 第一引數是生成的個數,第二個引數是 最小數,第三個為最大數。返回的是以逗號分割的字串
如 getnum(15, 10, 90)
在窗體中放乙個 label 然後,再新增放乙個按鈕……生成函式如下
function getnum(byval num as integer, byval min as integer, byval max as integer)
dim result, tmp as stringdim i, n, k as integerk = max - min
randomize()' 初始化隨機種子
for i = 1 to num '開始迴圈產生不重複數字tmp = ""
while (true) '生成數字
n = clng(rnd() * k + min)if n mod 2 = 1 then '判斷是否為奇數tmp = clng(n)
if instr(result, tmp) <= 0 then exit while '看有沒有重,有就重新生成
end if
end while
result = result & "," & nnext
getnum = mid(result, 2)' 去了第乙個逗號end function
3樓:匿名使用者
private sub command1_click()dim i as integer, a as integer, n as integer
randomize '它讓產生的隨機數不相同n = 0
do while n < 15
a = int(rnd * 81 + 10)if a mod 2 <> 0 then
label1.caption = label1.caption+"a"
n = n + 1
end if
loop
end sub
4樓:匿名使用者
sub aaa()
dim i as integer, a(14) as integerdim inttmp as integeri = 0
do while (i < 15)
inttmp = int(10 + rnd * 80)if inttmp mod 2 = 1 thena(i) = inttmp
label1(i).caption=inttmpi = i + 1
end if
loop
end sub
5樓:沙慧月
private sub command1_click()doa = int(rnd * 81 + 10)if a mod 2 <> 0 then
label1.caption = label1.caption & a & ";"
n = n + 1
end if
if n = 15 then exit doloop
end sub
6樓:匿名使用者
private sub form_click()dim b(1 to 15) as integerfor i = 1 to 15
n = int(rnd * 100) + 90print n;
if n / 2 <> n \ 2 thenb(i) = n
end if
next i
for i = 1 to 15
if b(i) <> 0 then
print b(i);
end if
next i
end sub
vb程式設計利用隨機函式產生15個隨機整數,區間為10-90輸出其中最小的三個奇數的和 5
7樓:聽不清啊
private sub command1_click()dim a(10 to 90) as integerrandomize
for i = 1 to 15
x = int(81 * rnd) + 10a(x) = 1
print x;
next i
i = 11
while a(i) = 0
i = i + 2
wend
print i;
s = j
for j = i + 2 to 90 step 2if a(j) = 1 then
k = k + 1
s = s + j
print "+"; j;
if k = 2 then exit forend if
next j
print "="; s
end sub
8樓:匿名使用者
private sub command1_click()dim d(15) as integer
dim x as integer
dim num as integer
dim i as integer
dim j as integer
randomize
donum = 0
for i = 1 to 15
d(i) = int((81) * rnd + 10)if d(i) mod 2 = 1 then num = num + 1
next i
loop until num >= 3
'輸出15和數
for i = 1 to 15
print d(i);
next i
'排序for i = 1 to 14
for j = i + 1 to 15
if d(i) > d(j) then
x = d(i)
d(i) = d(j)
d(j) = x
end if
next j
next i
'輸出結果
x = 0
num = 0
for i = 1 to 15
if d(i) mod 2 = 1 thennum = num + 1
x = x + d(i)
print d(i);
end if
if num = 3 then exit fornext i
print "它們的和為:"; x
end sub
9樓:匿名使用者
要是產生的隨機數都是偶數怎麼辦?
vb程式設計編寫乙個程式使隨機產生10個10到99之間的奇數並以5個換一行的形式顯示
10樓:匿名使用者
dim str as string = "生成的陣列為" & vbcrlf, sum as integer = 0, i, j, temp as integer
dim a(10) as integer
for i = 1 to 10
a(i) = 2 * int(rnd() * 45 + 5) + 1str = str & a(i) & " "
if i mod 5 = 0 then
str = str & vbcrlf
end if
next
textbox6.text = str
執行結果:
生成的陣列為
73 59 63 37 37
79 11 79 83 73
利用vb隨機函式產生20個10到99的隨機整數存入一維陣列a,找出其中所有奇數並統
11樓:匿名使用者
如果是病毒感染導致的發熱,是容易反**熱的,一般病程在一周左右。還是建議檢查血常規,了解感染情況,明確診斷,再對症用藥。注意多給孩子喝水。
其次,還有一種情況,就是如果有血象的公升高,抗生素不能控制感染,也是有可能導致發熱的。所以還是建議先檢查血常規,了解感染的情況,對症用藥。
你好發燒是很多疾病都會有的症狀,一定要把引起發燒的病治好了,燒才能真正的退下來。如果還有咳嗽、流鼻涕等感冒症狀,需要用雙撲偽麻分散片、小兒氨酚黃那敏顆粒等感冒藥**。體溫在三十八點五度以上時,可用美林或泰諾林退燒**;體溫在三十八點五度以下時,或勤些用溫水擦浴以降溫,或用兵兵退熱貼敷額以降溫能起到退熱護腦的作用。
12樓: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編寫程式利用隨機函式rnd生成十個10-99之間的整數並分別求出偶數與奇數的個數
13樓:
sub t()
dim i奇數 as integer
i奇數 = 0
dim i偶數 as integer
i偶數 = 0
dim allnumber as stringdim itemp as integer
for i = 1 to 10
itemp = rnd * 90 + 10if i > 1 then
allnumber = allnumber & ","
end if
allnumber = allnumber & itempif itemp mod 2 = 0 theni偶數 = i偶數 + 1
else
i奇數 = i奇數 + 1
end if
next
debug.print "allnumber = " & allnumber
debug.print "i奇數 = " & i奇數debug.print "i偶數 = " & i偶數end sub
靠,居然沒有注意,沒有給分的。
算了,便宜你了
用vb程式利用隨機函式生成一組數存放在陣列中,把該陣列的值顯示在圖形框中,然後下標為奇數的陣列元素從數 55
14樓:匿名使用者
private sub command1_click()dim a(10) as long, b(10) as long '是宣告兩個陣列
for i = 1 to 10
a(i) = rnd * 1000 + 1 '隨機數範圍【1,1000】
picture1.print a(i); '**框1中輸出next i
k = 0 '陣列2的計數器
for i = 1 to 10
if i mod 2 = 0 then '挑出下標偶數的數內組元素k = k + 1 '新陣列計容數
b(k) = a(i) '新陣列
end if
next i
for i = 1 to k
picture2.print b(i); '新陣列輸出next i
end sub
vb編寫程式利用隨機函式rnd生成
n 10 int 90 rnd st st n forj 2 to n n1 n1 1 exit for text1.text st text2.text n n1 private sub mand1 click dim i as integer,j as integer,n as integer,...
vb程式設計題 隨機產生兩個2位整數,使用choose函式隨機產生操作符給使用者出一道算
什麼時候要,我可以寫 如何用vb設計乙個程式,隨機產生二十個三位整數 sub s randomize 初始化隨機變數 for i 1 to 20 做20次迴圈debug.print int 100 rnd 900 輸出隨機數到立即視窗 next end sub 樓上連陣列都沒有定義,也沒有把產生的數...
利用rand函式產生100以內的隨機數,然後用氣泡排序法對這數進行降序排
1 輸入 2 排序抄 3 輸出。參考 如下 include int main for i 0 i 10 i 輸出 利用隨機函式產生10個100以內的整數,並從小到大的順序排序並輸出。include using namespace std int a 10 測試陣列 duvoid print 輸出陣列...