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
如何用python編寫產生1100的隨機數程式
可以使用random包的randint函式import random x random.randint 1,100 隨機數的範圍是1 100,包含首尾 需要用到random模組 import random n random.randint 1,10 會生成一個1到10的隨機整數。插入列表即可 imp...
元素的陣列。隨機所有元素並排序vb編寫
private sub mand1 click randomize dim a 20 as integer for i 1 to 20 a i int rnd 101 100 print a i next i for i 1 to 20 for j 1 to 20 i if a j a j 1 th...
一位小數乘二位整數100道,二位小數乘整數怎麼列豎式
一個兩位小數乘一個整數,積是 d a 一位小數 b 兩位小數 c 整數 d 以上三種都有可能 二位小數乘整數怎麼列豎式 先把小數擴大一定的倍數變成整數,再按整數的乘法乘出豎式結果,最後點上小數點。舉例說明如下 1.23 5的豎式計算如下 列豎式的時候,先把1.23擴大100倍變成123,再用123 ...