在vb中从键盘中输入数放在数组中,如1,2,3,4,5,6,7,8,9,10再对调为10,9,8,7,6,5,4,3,2,1
展开全部
使用冒泡排序法
更多追问追答
追问
在vb 中也行吗?能讲详细点吗
追答
Option Base 1
Private Sub Command1_Click()
Dim a
Dim b As Integer
Dim i As Integer
Dim j As Integer
a = Array(6, 3, 7, 8, 2, 1)
Print "排序前为";
For i = 1 To 6
Print a(i);
Next i
For i = 1 To 5
For j = 1 To 6 - i
If a(j) > a(j + 1) Then
b = a(j + 1)
a(j + 1) = a(j)
a(j) = b
End If
Next j
Next i
Print "排序后为";
For i = 1 To 6
Print a(i);
Next i
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询