1樓:火鍋兎
被計算機2級考試折磨的可憐娃兒~
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個隨機二位整數
randomize
for i = 1 to 50
mr(i) = int((90 * rnd) + 10) '10~99
t = t + mr(i)
next
'每行10個輸出
so = ""
for i = 1 to 50
so = so & mr(i) & " "
if 0 = (i mod 10) then so = so & vbcrlf
next
debug.print so
'輸出總和
debug.print "sum:" & t & vbcrlf
'氣泡排序
for i = 1 to 49
b = false
for j = 50 to (i + 1) step -1
if mr(j - 1) > mr(j) then
x = mr(j - 1): mr(j - 1) = mr(j): mr(j) = x: b = true
end if
next
if not b then exit for
next
'每行10個輸出
so = ""
for i = 1 to 50
so = so & mr(i) & " "
if 0 = (i mod 10) then so = so & vbcrlf
next
debug.print so
end sub
一、建立一個10個元素的int陣列, 1) 隨機賦值 100以內的整數 2) 按降序排序 3) 輸出排序後的陣列元素 30
3樓:兄弟連教育北京總校
#include
#include
#include
int main()
for(i = 0; i < 10; i ++)printf("%d ", a[i]);}
4樓:_葉子妞妞
這個 不就是昨天那個嘛...
vb利用隨機函式產生10個兩位數素數,存到陣列a中,要求陣列元素互不相同,最後按升序排序輸出
5樓:匿名使用者
dim a(10), x as integerdim str as string = ""
dim di as boolean = truedim n as integer
for i = 1 to 10
dodo
n = int(rnd() * 1000 + 10)loop until issushu(n)if i > 1 then
for x = 1 to i - 1
if a(x) = n then
msgbox(str & " 最新 " & n)di = false
end if
next
end if
loop until di = true
a(i) = n
str = str & a(i) & " "
randomize(10)
next
for i = 1 to 10
for j = 1 to 10 - i
if a(j) > a(j + 1) thenx = a(j + 1)
a(j + 1) = a(j)
a(j) = x
end if
next j
next i
for i = 1 to 10
str = str & a(i) & " "
next
textbox6.text = str
怎麼編寫程式MATLAB,產生兩位隨機整數,輸出其中小
如三秋 根據目的判斷,需要調取到的函式有randi mod mean find,分別用於產生隨機整數 判斷是否為偶數 計算平均數 尋找滿足條件元素的下標。如下 clc clear n randi 10,99 1,20 產生隨機數,在10到99之間的均勻隨機數 a mean n 計算平均數 n fin...
如何使vb產生隨機正整數,如何使VB中Rnd函式產生的隨機數是在 0,1 內?
zheng0823的回答有點小問題,你那樣永遠得不到38,應該37改為38 同理你command2的事件裡28改為29,不然最大只能得到66因為rnd函式返回的範圍是 0,1 包含0 但不包含1 還有沒有初始化隨機數種子 修改後的 private sub command1 click randomi...
用vb編寫利用隨機函式產生10 99之間(包括10和
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 n...