3个回答
展开全部
Dim a(15) As Integer
Dim str As String
str = ""
Dim temp As Integer
For i = 1 To 15
a(i) = Int(Rnd() * 90) + 10
Next
For i = 1 To 15
For j = 1 To 15 - i
If a(j) < a(j + 1) Then
temp = a(j + 1)
a(j + 1) = a(j)
a(j) = temp
End If
Next j
Next i
For i = 1 To 15
str = str & a(i) & " "
Next
Label1.caption = str
Dim str As String
str = ""
Dim temp As Integer
For i = 1 To 15
a(i) = Int(Rnd() * 90) + 10
Next
For i = 1 To 15
For j = 1 To 15 - i
If a(j) < a(j + 1) Then
temp = a(j + 1)
a(j + 1) = a(j)
a(j) = temp
End If
Next j
Next i
For i = 1 To 15
str = str & a(i) & " "
Next
Label1.caption = str
展开全部
'假设要比较的三个数输入在Text1,text2,text3,结果放在text4
Private Sub Command1_Click()
Dim a, b, c, d As Double
a = Val(Text1.Text)
b = Val(Text2.Text)
c = Val(Text3.Text)
If a < b Then d = a: a = b: b = d
If b < c Then d = b: b = c: c = d
If a < b Then d = a: a = b: b = d
Text4.Text = a & " , " & b & " , " & c
End Sub
Private Sub Command1_Click()
Dim a, b, c, d As Double
a = Val(Text1.Text)
b = Val(Text2.Text)
c = Val(Text3.Text)
If a < b Then d = a: a = b: b = d
If b < c Then d = b: b = c: c = d
If a < b Then d = a: a = b: b = d
Text4.Text = a & " , " & b & " , " & c
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
For i = 1 To 10
For j = 1 To 10 - i
If a(j) > a(j + 1) Then
temp = a(j + 1)
a(j + 1) = a(j)
a(j) = temp
End If
Next j
Next i
Dim i As Integer
Dim j As Integer
Dim temp As Integer
Private Sub Command1_Click()
Dim s As String
s = ""
Print "原数组为:"
For i = 1 To 10
s = s & a(i) & " "
Next i
Print s
For i = 1 To 10
For j = 1 To 10 - i
If a(j) > a(j + 1) Then
temp = a(j + 1)
a(j + 1) = a(j)
a(j) = temp
End If
Next j
Next i
s = ""
Print "排序后的数组为:"
For i = 1 To 10
s = s & a(i) & " "
Next i
Print s
End Sub
Private Sub Form_Load()
Dim str As String
str = "33,26,96,41,25,99,33,51,21,20"
a(1) = 33
a(2) = 26
a(3) = 96
a(4) = 41
a(5) = 25
a(6) = 99
a(7) = 33
a(8) = 51
a(9) = 21
a(10) = 20
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询