字符串数组的遍历和排序

发布网友 发布时间:2022-04-26 19:00

我来回答

1个回答

热心网友 时间:2022-04-18 09:03

已经测试通过 满意就给分吧
Private Sub Command1_Click()
Dim a(5)
a(0) = 100
a(1) = 123
a(2) = 456
a(3) = 333
a(4) = 122
a(5) = 88
MsgBox "现在开始遍历输出", , "提示"
For i = 0 To UBound(a)
MsgBox "a(" & i & ")=" & a(i), , "提示"

Next
MsgBox "现在开始冒泡排序输出", , "提示"
For i = 0 To UBound(a)
For ii = i To UBound(a)
If a(i) > a(ii) Then
tmp = a(ii)
a(ii) = a(i)
a(i) = tmp
End If
Next
Next

For i = 0 To UBound(a)
MsgBox "a(" & i & ")=" & a(i), , "提示"

Next
End Sub

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com