| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1612 人关注过本帖
标题:[求助] Vb.net 输入10个数字排序
只看楼主 加入收藏
菜小鸟
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2006-3-18
收藏
 问题点数:0 回复次数:3 
[求助] Vb.net 输入10个数字排序

Vb.net 输入10个数字排序 输入10个数字 按大小输出
那位高手把完整的代码发一下

搜索更多相关主题的帖子: 数字 输入 
2006-03-20 18:34
zhangwei
Rank: 1
等 级:新手上路
威 望:1
帖 子:277
专家分:0
注 册:2005-5-3
收藏
得分:0 

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim arr(6) As Double
arr(1) = CDbl(TextBox1.Text)
arr(2) = CDbl(TextBox2.Text)
arr(3) = CDbl(TextBox3.Text)
arr(4) = CDbl(TextBox4.Text)
arr(5) = CDbl(TextBox5.Text)
arr(6) = CDbl(TextBox6.Text)

Call BubbleSort(arr)

TextBox1.Text = CStr(arr(1))
TextBox2.Text = CStr(arr(2))
TextBox3.Text = CStr(arr(3))
TextBox4.Text = CStr(arr(4))
TextBox5.Text = CStr(arr(5))
TextBox6.Text = CStr(arr(6))
End Sub

Sub BubbleSort(ByVal List() As Double)
Dim first, last, temp As Double
Dim i, j As Integer
first = LBound(List)
Last = UBound(List)
For i = first To last - 1
For j = i + 1 To last
If List(i) > List(j) Then
temp = List(j)
List(j) = List(i)
List(i) = temp
End If
Next
Next
End Sub


主动沟通......
2006-03-21 13:37
菜小鸟
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2006-3-18
收藏
得分:0 
谢谢了
多谢楼上的大哥
2006-03-21 14:48
huifeng2000
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2006-2-21
收藏
得分:0 





Dim x(10) As Integer
Dim m As Integer


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


Private Sub btn_continue_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn.Click
Try


If btn.Text = "继续" Then
x(m) = Convert.ToInt32(txt_input.Text)
m = m + 1
txt_input.Clear()
txt_input.Focus()

If m > 9 Then
btn.Text = "排序"
End If


Else

Dim i, j As Integer
Dim t As Integer
For i = 0 To 9
For j = 0 To 9 - i
If x(j) <= x(j + 1) Then
t = x(j)
x(j) = x(j + 1)
x(j + 1) = t
End If
Next
Next

For i = 0 To 9
Label2.Text += x(i).ToString + " "
Next
btn.Enabled = False
End If
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
End Class

[此贴子已经被作者于2006-3-21 16:46:39编辑过]


QQ.271969483
2006-03-21 16:43
快速回复:[求助] Vb.net 输入10个数字排序
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.049365 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved