小明基于插入排序思想设计了一个改进的排序算法。输入n个两位正整数到数组a,判断数组a中每个元素的奇偶性,若为奇数则将其放前插入适当位置,若为偶数则将其放后插入适当位置。排序完后数组a中所有奇数在前升序排序,偶数在后降序排序。程序代码如下:
Dim a(1 To 100) As Integer, n As Integer
Function moving( start As Integer, finish As Integer, st As Integer)
'将元素 a(finish)插入到元素 a(start)和元素 a(start+st)之间
Dim i As Integer, k As Integer k = a(finish)
For i = finish - st To start Step -st a(i + st) = a(i)
Next i a(start) = k
End Function
Private Sub Command1_Click()
Dim head As Integer, end1 As Integer, i As Integer, ans As String
' 将待排序的数存储在数组 a 的 a(1)至 a(n)中,并输入元素个数 n,代码略
head = 1: end1 = n + 1
Do While head < end1
If ① Then
For i = 1 To head - 1
If a(i) > a(head) Then Exit For
Next i
Call moving(i, head, 1)
head = ②
Else
For i = end1 To n
If a(i) < a(head) Then Exit For
Next i
Call moving( ③ )
End1 = end1 - 1
End If
Loop
For i = 1 To n
ans = ans + Str(a(i))
Next i
Text2.Text = ans End Sub 请回答下列问题: