资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

vb.net排序例题,vb排序代码

VB.NET中的“冒泡排序”问题

如果五个号码为数组元素(1)到(5),正确的排序过程:

创新互联公司专业为企业提供广河网站建设、广河做网站、广河网站设计、广河网站制作等企业网站建设、网页设计与制作、广河企业网站模板建站服务,10多年广河做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。

对于i = 1至4

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

N = A(L)

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

(L +1) =

结束如果下一页l

接下来,我

能够到第一台计算机来验证结果,然后分析程序。

VB.NET 程序 随机产生10个整数并进行排序

Public Class Form1

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

Dim N As Integer = 9

Randomize()

Dim xx(9) As Integer

For i As Integer = 0 To N

xx(i) = Int(Rnd() * 1000) '产生 [0,1000) 之间的整数

Next

For i As Integer = 0 To N - 1

For j As Integer = i + 1 To N

If xx(i) xx(j) Then

Dim temp As Integer = 0

temp = xx(i) : xx(i) = xx(j) : xx(j) = temp

End If

Next

Next

Dim sum As Integer = 0

For i As Integer = 0 To N

TextBox1.Text += xx(i) vbCrLf

sum += xx(i)

Next

TextBox1.Text += "最大值:" xx(9) vbCrLf "最小值:" xx(0) vbCrLf "平均值:" sum / 10

End Sub

End Class

VB.NET 2维数组排序排序和赋值问题

窗体上添加3个标签,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

'显示排序前的数据

Label1.Text = "排序前数据:" 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

'显示排序前的数据

Label2.Text = "排序后数据:" 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排序例题,vb排序代码
网站URL:http://www.cdkjz.cn/article/hssphj.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220