题型:填空题 题类:常考题 难易度:普通
高中信息技术综合库——枚举算法3
为实现上述功能程序如下,但加框处的代码有误,请改正。
Private Sub Command1_Click()
Dim n As Integer
Dim i As Integer, c As Integer
n = Val(Text1.Text)
List1.Clear
c = 0
If n Mod 2 = 0 Then
For ①
If Then ②
List1.AddItem n & "=" & i & "+" & n - i
c = c + 1
End If
Next i
Label2.Caption = "共有" & c & "种组合"
Else
Label2.Caption = "请输入一个大于 2 的偶数"
End If
End Sub
Function is Prime(x As Integer) As Boolean
Dim i As Integer
Is Prime = True
For i = 2 To Int(Sqr(x))
If x Mod i = 0 Then
Is Prime = False
Exit For
End If
Next i
End Function
① ②
试题篮