题型:填空题 题类:模拟题 难易度:普通
浙江省杭州市2016年信息技术高考模拟卷四
请根据算法将下列程序补充完整。
Dim a(1 To 45) As String
Dim b(1 To 45) As Integer
Private Sub FormLoad()
a(1) = "中国"
b(1) = 308 ‘45个代表团名称及奖牌数分别放在a(1)到a(45)及b(1)到b(45)中
End Sub
Private Sub Command1Click()
Dim i As Integer,j As Integer
Dim t As Integer,f As Integer
List1.Clear
For i = 1 To 3
For j = To 2 Step -1
If Then
f = a(j): a(j) = a(j - 1): a(j - 1) = f
t = b(j): b(j) = b(j - 1): b(j - 1) = t
End If
Next j
Next i
For i = 1 To 3
List1.AddItem "第" + Str(i) + "名" + a(i) + " 奖牌数" + Str(b(i))
Next i
End Sub
排序前 |
71 |
85 |
64 |
55 |
42 |
62 |
33 |
17 |
34 |
30 |
排序后 |
71 |
85 |
17 |
55 |
33 |
30 |
62 |
42 |
34 |
64 |
实现上述功能的VB程序如下,但加框处代码有错,请改正。
Const n=10
Dim a(1 To n) As Integer
Private Sub Command1_Click()
Dim i As Integer,j As Integer
Dim temp As Integer,flag As Boolean
'读取一组正整数,存储在数组a中,代码略
i=1:j=n
temp=a(j):flag=True
Do While i<j
If flag Then
If a(i) Mod 2=0 Then
a(j)=a(i)
j=j-1
flag=Not flag
Else
'{#blank#}1{#/blank#}
End If
Else
If a(j) Mod 2=1 Then
a(i)=a(j)
flag=Not flag
Else
j=j-1
End If
End If
Loop
' {#blank#}2{#/blank#}
'依次输出排序后的数据,代码略。
End Sub
试题篮