题型:填空题 题类:常考题 难易度:困难
浙江省金华市江南中学2019-2020学年高二下学期信息技术3月月考试卷
实现上述功能的VB程序如下,但横线处代码有错,请改正。
Const n = 8
Dim a(1 To n) As Integer
Private Sub Form_Load()
'排序前数据存储在数组a中,并在文本框Text1中显示代码略
End Sub
Private Sub Command1_Click()
Dim k As Integer, i As Integer, j As Integer, t As Integer
i = 1
Do While i <= n - 1
k = i
For j = i + 1 To n
If a(i) Mod 2 = 1 And a(k) Mod 2 = 0 Then '①
k = j
ElseIf a(k) Mod 2 = 0 And a(j) Mod 2 = 0 And a(j) > a(k) Then
k = j
End If
Next j
If k <> i Then
t = a(k): a(k) = a(i): a(i) = t
End If
i = i + k '②
Loop
'依次输出排序后的数据。代码略
End Sub
① ②
试题篮