题型:填空题 题类:常考题 难易度:困难
浙江省杭州市第二中学2015-2016学年高二下学期信息技术期中考试试卷
实现上述功能的VB代码如下, 但划线处代码有错,请改正。
Dim a(1 To 50) As Integer
Private Sub Command1_Click()
Dim i As Integer
k = 0: i = 3
Do While i <= 100
If ① prime(i) Then ‘⑴
k = k + 1
a(k) = i
End If
i = i + 2
Loop
For i = 2 To k
If ②a(i) = a(i +1)+2 Then ‘⑵
List1.AddItem Str(a(i - 1)) + "和" + Str(a(i))
End If
Next i
End Sub
Function prime(x As Integer) As Boolean
prime = False
For i = 2 To Int(Sqr(x))
If x Mod i = 0 Then
prime = True
Exit For
End If
Next i
End Function
① ②
试题篮