vb2010寫的:
創(chuàng)新互聯(lián)建站服務(wù)項(xiàng)目包括翁牛特網(wǎng)站建設(shè)、翁牛特網(wǎng)站制作、翁牛特網(wǎng)頁(yè)制作以及翁牛特網(wǎng)絡(luò)營(yíng)銷策劃等。多年來,我們專注于互聯(lián)網(wǎng)行業(yè),利用自身積累的技術(shù)優(yōu)勢(shì)、行業(yè)經(jīng)驗(yàn)、深度合作伙伴關(guān)系等,向廣大中小型企業(yè)、政府機(jī)構(gòu)等提供互聯(lián)網(wǎng)行業(yè)的解決方案,翁牛特網(wǎng)站推廣取得了明顯的社會(huì)效益與經(jīng)濟(jì)效益。目前,我們服務(wù)的客戶以成都為中心已經(jīng)輻射到翁牛特省份的部分城市,未來相信會(huì)繼續(xù)擴(kuò)大服務(wù)區(qū)域并繼續(xù)獲得客戶的支持與信任!
Private?Sub?Button7_Click(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?Button7.Click
Dim?str?As?String?=?""
Dim?a(30)?As?Integer
Dim?temp?As?Integer
str?=?str??"生成的30個(gè)隨機(jī)數(shù)字是?"??vbCrLf
For?i?=?1?To?30
a(i)?=?Int(Rnd()?*?50?+?1)
str?=?str??a(i)??"?"
If?i?Mod?10?=?0?Then
str?=?str??vbCrLf
End?If
Next
str?=?str??vbCrLf
For?i?=?1?To?30
For?j?=?1?To?30?-?i
If?a(j)??a(j?+?1)?Then
temp?=?a(j?+?1)
a(j?+?1)?=?a(j)
a(j)?=?temp
End?If
Next?j
Next?i
str?=?str??"排序后的數(shù)字是?"??vbCrLf
For?i?=?1?To?30
str?=?str??a(i)??"?"
If?i?Mod?10?=?0?Then
str?=?str??vbCrLf
End?If
Next
TextBox6.Text?=?str
End?Sub
運(yùn)行結(jié)果:
生成的30個(gè)隨機(jī)數(shù)字是
36 27 29 15 16 39 1 39 41 36
3 21 44 40 19 49 44 3 48 19
27 39 3 30 24 15 32 33 14 14
排序后的數(shù)字是
49 48 44 44 41 40 39 39 39 36
36 33 32 30 29 27 27 24 21 19
19 16 15 15 14 14 3 3 3 1
Private Sub Command1_Click()
Dim a(1 To 100) As Integer
Dim i As Integer, j As Integer, k As Integer
For i = 1 To 100 '給數(shù)組a一百個(gè)元素賦值,并換每行十個(gè)數(shù)字輸出來窗體上
a(i) = Int(Rnd * 101)
k = k + 1
Print Tab((k - 1) * 5); a(i);
If k = 10 Then k = 0: Print
Next i
For i = 100 To 2 Step -1 '用冒泡排序法對(duì)數(shù)組進(jìn)行排序
For j = 1 To i - 1
If a(j) a(j + 1) Then
t = a(j): a(j) = a(j + 1): a(j + 1) = t
End If
Next j
Next i
For i = 1 To 100 '輸出排好序的數(shù)組
k = k + 1
Print Tab((k - 1) * 5); a(i);
If k = 10 Then k = 0: Print
Next i
End Sub
給你一個(gè)最簡(jiǎn)單的冒泡排序代碼:
將三個(gè)數(shù)放到一個(gè)數(shù)組中。
a(0)=val(text1.text):a(1)=val(text2.text):a(2)=val(text3.text)
dim flag as Boolean,temp as Integer
for i = 0 to 2
flag = true
for j = 2 to 1
if a(j)a(j-1) then
temp = a(j-1)
a(j-1) = a(j)
a(j) = temp
flag = false
end if
next j
if flag then Exit For
next i
text4.text=a(0):text5.text=a(1):text6.text=a(2)