Dim a(10) As Integer
Private Sub Command1_Click()
For i = 1 To 8
x = Int(90 * Rnd) + 10
a(i) = x
Text1 = Text1 & x & " "
Next i
End Sub
Private Sub Command2_Click()
For i = 1 To 7
For j = 1 To 8 - i
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 8
Text2 = Text2 & a(i) & " "
Next i
End Sub
Private Sub Form_Load()
Text1 = ""
Text2 = ""
End Sub
在VB编程中求最大和最小数
首先,我们需要一个数组来存储这些数。例如,我们有五个数:X[1] = 2, X[2] = 5, X[3] = 1, X[4] = 4, X[5] = 3。我们将这些数赋给数组。然后,我们开始冒泡排序过程。在这个过程中,我们不断地比较相邻的两个元素,如果它们的顺序不正确(即第一个数大于第二个数),我们就交换...
vb冒泡排序代码
Private Sub Command1_Click()Dim num(1 To 10) As Integer Dim i, j, t As Integer For i = 1 To 10 num(i) = Int((100 - 0 + 1) * Rnd + 0)Next For i = 1 To 10 For j = i + 1 To 10 If num(i) > num(j) Then t = num(i)num(i) = num(j)num(j) =...
vb冒泡法排序步骤
dim A(10) as integer dim I,J as integer dim temp as integer '临时交换用 '初始化随机函数 randmize '取10个随机数(范围100以内)并存放到数组中 for I=0 to 9 A(I)=Int(Rnd*100)next I '开始冒泡排序 for I=0 to 8 for J=I+1 to 9 '冒泡原理(大的数下沉,小的数上浮)...
vb随机数产生,并冒泡排序我的代码是下面
t = "" '添上这句就可以了 For i = 0 To 100 - 1 t = t & a(i) & " " Next i TextBox2.Text = t
vb冒泡排序代码是什么?
冒泡排序法:Option Explicit Private Sub Form_Click()Const N = 10 Dim i%, a(1 To N), m%, j%, t Randomize For i = 1 To N '随机输出10个1位数 a(i) = Int(Rnd * 9 + 1)Print a(i);Next i Print For i = 1 To N - 1 '采用冒泡排序 For j = 1 To N -...
求VB冒泡程序代码,详细点的,最好配图谢谢
sub function 冒泡排序(byref b() , byval n0 as integer, byval n1 as integer)' 冒泡排序之升序 '参数:b() 数组,此处使用变体类型,效率低但通用,必须是地址传递参数 ' n0,n1 数组元素的起止索引,整型,dim i as integer dim j as integer dim Tme '作为交换值的变量,与b类型同...
VB的排序法的代码
排序的各类很多,最简单的冒泡排序代码如下:Private Sub Command1_Click()Dim a(), i As Integer, j As Integer, tmp As Integer a = Array(1, 3, 2, 5, 4, 6, 9, 7, 8, 0)Print Join(a, ",")For i = 0 To UBound(a)For j = i + 1 To UBound(a)If a(j) < a(i...
VB冒泡排序法
我每次的做法是:for i=0 to 4 for j=i+1 to 4 if a(j)< a(i) then 交换 next next
vb 产生10个两位随机整数,用冒泡排序法对10个数按升序排序
为您推荐: vb语言 vb编程设计例题100例 vb 整数 vb整数代码 vb判断整数 vb表示整数 vb随机整数 vb整数型是什么 vb & vb随机生成数字 其他类似问题2012-05-06 vb,产生10个两位随机整数,用冒泡排序法对10个数升序排列 9 2012-05-23 VB随机产生10个两位数整数(正整数),要求分别用选择排序法....
VB编程题用冒泡法从大到小输出,并另单独输出最大值和最小值、平均值...
Private Sub Command1_Click()Dim a(11) As Single For i = 1 To 10 Do b = InputBox("请你输入10个数字", "第 " & i & "个", 10)Loop Until IsNumeric(b)a(i) = b Next i For i = 1 To 10 For j = 1 To (i - 1)If a(j) < a(i) Then Call Swap(a(i), a...