真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

vb.net大小排序,vb 排序

VB.NET中,比較四個數(shù)字的大小 代碼

用不到2個命令按鈕 1個就夠

創(chuàng)新互聯(lián)公司擁有網(wǎng)站維護(hù)技術(shù)和項(xiàng)目管理團(tuán)隊(duì),建立的售前、實(shí)施和售后服務(wù)體系,為客戶提供定制化的成都網(wǎng)站設(shè)計(jì)、做網(wǎng)站、網(wǎng)站維護(hù)、服務(wù)器機(jī)柜租用解決方案。為客戶網(wǎng)站安全和日常運(yùn)維提供整體管家式外包優(yōu)質(zhì)服務(wù)。我們的網(wǎng)站維護(hù)服務(wù)覆蓋集團(tuán)企業(yè)、上市公司、外企網(wǎng)站、商城網(wǎng)站制作、政府網(wǎng)站等各類型客戶群體,為全球1000多家企業(yè)提供全方位網(wǎng)站維護(hù)、服務(wù)器維護(hù)解決方案。

在按鈕的過程中寫如下代碼

dim x as long , y as long ,z as long ,j as long ,n as long

dim k as integer

x = val(text1.text)

y = val(text2.text)

z = val(text3.text)

j = val(text4.text)

if x = then k = k+1

if y= then k = k+1

if z= then k = k+1

if j= then k = k+1

' 若輸入的數(shù)有負(fù)數(shù) 則必須先在這里寫下 n=-.....()

do

if x 0 and n = x then

text5.text = text5.text " " x

k = k +1

end if

if y 0 and n = then

text5.text = text5.text " " y

k = k +1

end if

if z 0 and n = z then

text5.text = text5.text " " z

k = k +1

end if

if j 0 and n = j then

text5.text = text.text " " j

k = k +1

end if

if k = 4 then exit for

n=n+1

loop

這是VB的代碼。。。。 不知道.net 適用不

vB.net語言編寫N個數(shù)字?jǐn)?shù)組排序可自定義數(shù)組長度的

Dim d() As Integer

Dim n As Integer

Dim i As Integer

Dim j As Integer

Dim T As Integer

n = Val(InputBox("請輸入n,確定數(shù)組的元素個數(shù)"))

ReDim d(n)

'用隨機(jī)函數(shù)生成正整數(shù)數(shù)組

Randomize

For i = 1 To n

d(i) = Int(Rnd * 100 + 1)

Next i

'輸出

Print

For i = 1 To n

Print d(i),

Next i

'從小到大排序

For i = 1 To n - 1

For j = i + 1 To n

If d(i) d(j) Then

T = d(i)

d(i) = d(j)

d(j) = T

End If

Next j

Next i

'輸出

Print

For i = 1 To n

Print d(i),

Next i

求vb.net(vb2010)程序代碼 產(chǎn)生30個50以內(nèi)的隨機(jī)正整數(shù),將他們從大到小排序后輸出

vb2010寫的:

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個隨機(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個隨機(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

VB.NET 2維數(shù)組排序排序和賦值問題

窗體上添加3個標(biāo)簽,1個按鈕,在按鈕的單擊事件里寫代碼,如下:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim a(,) As Integer = {{5, 6}, {1, 3}, {8, 9}, {72, 1}, {63, 4}}

Dim Temp As Integer

Dim i As Integer

Dim j As Integer

Dim x As Integer

Dim y As Integer

'顯示排序前的數(shù)據(jù)

Label1.Text = "排序前數(shù)據(jù):" vbCrLf

For i = 0 To 4

Label1.Text = Label1.Text a(i, 0) " " a(i, 1) vbCrLf

Next

For i = 0 To 3

For j = i + 1 To 4

If a(i, 0) a(j, 0) Then

Temp = a(i, 0)

a(i, 0) = a(j, 0)

a(j, 0) = Temp

Temp = a(i, 1)

a(i, 1) = a(j, 1)

a(j, 1) = Temp

End If

Next

Next

'顯示排序前的數(shù)據(jù)

Label2.Text = "排序后數(shù)據(jù):" vbCrLf

For i = 0 To 4

Label2.Text = Label2.Text a(i, 0) " " a(i, 1) vbCrLf

Next

'把第3行元素賦予X,Y

x = a(2, 0)

y = a(2, 1)

'輸出X,Y

Label3.Text = "X=" x vbCrLf "Y=" y

End Sub

編寫一個 VB.NET 程序,產(chǎn)生 100 個 100 以內(nèi)的隨機(jī)數(shù),將他們從大到小排序后輸出

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一百個元素賦值,并換每行十個數(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

Print

Print

For i = 100 To 2 Step -1 '用冒泡排序法對數(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

vb.net的隨機(jī)3個數(shù)字,然后排序一下

給你一個最簡單的冒泡排序代碼:

將三個數(shù)放到一個數(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)


文章名稱:vb.net大小排序,vb 排序
文章URL:http://weahome.cn/article/hoeohh.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部