Dim d() As Integer
創(chuàng)新互聯(lián)2013年至今,是專業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項目網(wǎng)站設(shè)計制作、網(wǎng)站建設(shè)網(wǎng)站策劃,項目實(shí)施與項目整合能力。我們以讓每一個夢想脫穎而出為使命,1280元錦江做網(wǎng)站,已為上家服務(wù),為錦江各地企業(yè)和個人服務(wù),聯(lián)系電話:13518219792
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
'輸出
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
'輸出
For i = 1 To n
Print d(i),
Next i
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ListBox1.Items.Add("Apple")
ListBox1.Items.Add("Cat")
ListBox1.Items.Add("Yellow")
ListBox1.Items.Add("Guilty")
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ListBox1.Sorted = True
End Sub
End Class
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
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數(shù)字排序 vbs排序
轉(zhuǎn)載來源:http://vcdvsql.cn/article16/ddcsgdg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供App設(shè)計、自適應(yīng)網(wǎng)站、虛擬主機(jī)、網(wǎng)站導(dǎo)航、靜態(tài)網(wǎng)站、響應(yīng)式網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)