排序前 | 78 | 30 | 64 | 39 | 49 | 4 | 8 | 32 | 18 | 32 |
排序后 | 39 | 49 | 83 | 4 | 8 | 18 | 30 | 32 | 64 | 78 |
实现上述功能的VB程序如下,但加框处代码有误,请改正。
Const n = 10
Dim d(1 To n) As Integer
Private Sub Command1_Click()
Dim i As Integer, j As Integer, t As Integer
'读取一组正整数,存储在数组d中,代码略
i = 1
Do While i <= n - 1
For j = n To i + 1 Step -1
If d(j) Mod 2 = d(j - 1) Mod 2 Then
If d(j) > d(i) Then '(1)________
t = d(j): d(j) = d(j - 1): d(j - 1) = t
End If
Else '(2)________
t = d(j): d(j) = d(j - 1): d(j - 1) = t
End If
Next j
i = i + 1
Loop
'依次输出排序后的数据,代码略
End Sub

同类型试题

y = sin x, x∈R, y∈[–1,1],周期为2π,函数图像以 x = (π/2) + kπ 为对称轴
y = arcsin x, x∈[–1,1], y∈[–π/2,π/2]
sin x = 0 ←→ arcsin x = 0
sin x = 1/2 ←→ arcsin x = π/6
sin x = √2/2 ←→ arcsin x = π/4
sin x = 1 ←→ arcsin x = π/2


y = sin x, x∈R, y∈[–1,1],周期为2π,函数图像以 x = (π/2) + kπ 为对称轴
y = arcsin x, x∈[–1,1], y∈[–π/2,π/2]
sin x = 0 ←→ arcsin x = 0
sin x = 1/2 ←→ arcsin x = π/6
sin x = √2/2 ←→ arcsin x = π/4
sin x = 1 ←→ arcsin x = π/2

