题型:综合题 题类:常考题 难易度:普通
浙江省温州市新力量联盟2018-2019学年高二下学期信息技术期末联考试卷
Dim a(1 To 1000) As Integer
Dim n As Integer, p As Integer, q As Integer
Private Sub Command1_Click() '生成随机数据
n = Val(Text2.Text)
If n Mod 2 = 0 Then p = n - 1: q = n Else p = n: q = n - 1
'p,q 分别为生成的数列的奇数位和偶数位最大下标
'以下代码为生成随机数并按要求排序输出,代码略
End Sub
Private Sub Command2_Click() '添加数据
Key = Val(Text3.Text)
If Key Mod 2 = 0 Then
i = 1: j = p: p = p + 2
Else
i = 2: j = q: q = q + 2
End If
Do While i <= j
m = (i + j) / 2
If Key Mod 2 = 0 And m Mod 2 = 0 Then m = m - 1
If Key Mod 2 = 1 And m Mod 2 = 1 Then m = m - 1
If Then i = m + 2 Else j = m – 2
Loop
If Key Mod 2 = 0 Then '插入一个偶数
For k =
a(k) = a(k - 2)
Next k
a(k) = Key
Else
'插入一个奇数,代码略
End If
If p > q Then n = p Else n = q
For i = 1 To n
s = s + Str(a(i)) + ","
Next i
Text1.Text = s
End Sub
试题篮