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

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

vb.net冒泡法 冒泡排序法vb

在VB.NET中X為 4,9,12,15,22,33,44,66,72,84,87,92,96,98,99 Y為6,8,12,16,24,31,68,71,73,74,81,93,94將X

Imports System.Text.RegularExpressions

創(chuàng)新互聯(lián)是一家專注于網(wǎng)站設(shè)計、成都網(wǎng)站設(shè)計與策劃設(shè)計,烏蘭網(wǎng)站建設(shè)哪家好?創(chuàng)新互聯(lián)做網(wǎng)站,專注于網(wǎng)站建設(shè)十余年,網(wǎng)設(shè)計領(lǐng)域的專業(yè)建站公司;建站業(yè)務(wù)涵蓋:烏蘭等地區(qū)。烏蘭做網(wǎng)站價格咨詢:18982081108

Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim x, y As String

x = "4,9,12,15,22,33,44,66,72,84,87,92,96,98,99"

y = "6,8,12,16,24,31,68,71,73,74,81,93,94"

Dim g() As Integer

g = Array.ConvertAll((x "," y).Split(","), New Converter(Of String, Integer)(AddressOf strToint))

System.Array.Sort(g)

Dim g_str() As String

g_str = Array.ConvertAll(g, New Converter(Of Integer, String)(AddressOf IntTostr))

Dim My_text As String = Join(g_str, ",")

My_text = Regex.Replace(My_text, "\b(\w+),(?=\1)\b", "") 'My_text是最終結(jié)果

End Sub

Public Shared Function strToint(ByVal bs As String)

Return CInt(bs)

End Function

Public Shared Function IntTostr(ByVal bs As Integer)

Return CStr(bs)

End Function

End Class

My_text是最終結(jié)果,重復(fù)的12被自動剔除了

vb.net冒泡排序法代碼

試試看:

For?i?=?LBound(moto)?To?UBound(moto)?-?1

For?j?=?LBound(moto)?To?UBound(moto)?-?1?-?i

If?moto(j)??moto(j?+?1)?Then

t?=?moto(j)

moto(j)?=?moto(j?+?1)

moto(j?+?1)?=?t

End?If

Next?j

Next?i

For?i?=?LBound(moto)?To?UBound(moto)

Print?moto(i);

Next?i

VB.NET中的“冒泡排序”問題

如果五個號碼為數(shù)組元素(1)到(5),正確的排序過程:

對于i = 1至4

對于L = 1到5 - 如果A(L)(L +1)

N = A(L)

A(L),= A(L +1)

(L +1) =

結(jié)束如果下一頁l

接下來,我

能夠到第一臺計算機來驗證結(jié)果,然后分析程序。

使用vb.net編寫一個函數(shù),函數(shù)只有一個參數(shù)

首先在窗體上添加Button1,ListBox1,下面是完整代碼

Public?Class?Form1

Public?Sub?BubbleSort(ByVal?arr()?As?Integer)?'冒泡法排序

Dim?temp?As?Double

Dim?i,?j?As?Integer

For?i?=?0?To?arr.GetUpperBound(0)?-?1

For?j?=?i?+?1?To?arr.GetUpperBound(0)?-?1

If?arr(i)??arr(j)?Then

temp?=?arr(j)

arr(j)?=?arr(i)

arr(i)?=?temp

End?If

Next

Next

End?Sub

Private?Sub?Button1_Click(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?Button1.Click?'調(diào)用

Dim?arr()?As?Integer?=?{55,?22,?33,?11,?77,?88}

BubbleSort(arr)?'調(diào)用排序過程

Me.ListBox1.Items.Clear()

For?i?=?0?To?arr.GetUpperBound(0)?-?1?'顯示排序后結(jié)果

Me.ListBox1.Items.Add(arr(i).ToString)

Next

End?Sub

End?Class


網(wǎng)站標(biāo)題:vb.net冒泡法 冒泡排序法vb
文章來源:http://weahome.cn/article/hjjgpi.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部