题型:综合题 题类:常考题 难易度:普通
浙江省高中信息技术 排序算法及程序实现同步练习
实现上述功能的VB程序如下,在划线处填入合适的代码。
Const n=10
Dim a(1 To n)As Integer
Private Sub Command1_Click()
Dim i As Integer, j As Integer, t As Integer
Dim k As Integer, bottom As Integer
‘获取排序前数据,依次存储在数组a中,并在文本框Text1中显示。代码略
bottom = n: i = 1
Do While i <= bottom - 1
k = i: j = bottom
Do While j > i
If a(j) < a(k) Then
k = j
Elself a(j) = a(i) Then
a(j) = a(bottom)
IfThen k=j
bottom = bottom - 1
End If
j = j - 1
Loop
If k <> i Then
t = a(k): a(k) = a(i): a(i) = t
Else
End If
Loop
For i = 1 To
Text2. Text = Text2.Text + Str(a(i))
Next i
End Sub
试题篮