请教一道VB的程序填空题
本程序用于验证任何一个大于6的偶数均可以表示为2个素数的和。如:14=3+11,14=7+7。待验证的偶数从文本框TxtInput输入。所有满足上述条件的素数对(2个素数...
本程序用于验证任何一个大于6的偶数均可以表示为2个素数的和。如:14=3+11,14=7+7。待验证的偶数从文本框TxtInput输入。所有满足上述条件的素数对(2个素数)都显示在窗体上。
Private Sub Form_Click()
Dim n As Integer, i As Integer, j As Integer
n =___________
For i = 3 To n - 2 Step 2
If ____________ Then
If n - i >= i And prime(n - i) Then
Print n; "="; i; "+"; n - i
End If
End If
Next i
End Sub
Private Function prime(n As Integer) As Boolean
Dim i As Integer, j As Integer, flg As Boolean
prime False
flg = True
For i = 2 To Sqr(n)
If n Mod i = 0 Then ___________
Next i
If ___________ Then prime = True
End Function 展开
Private Sub Form_Click()
Dim n As Integer, i As Integer, j As Integer
n =___________
For i = 3 To n - 2 Step 2
If ____________ Then
If n - i >= i And prime(n - i) Then
Print n; "="; i; "+"; n - i
End If
End If
Next i
End Sub
Private Function prime(n As Integer) As Boolean
Dim i As Integer, j As Integer, flg As Boolean
prime False
flg = True
For i = 2 To Sqr(n)
If n Mod i = 0 Then ___________
Next i
If ___________ Then prime = True
End Function 展开
2个回答
展开全部
Private Sub Form_Click()
Dim n As Integer, i As Integer, j As Integer
n =___TextInput.text________
For i = 3 To n - 2 Step 2
If ___((n mod 2)=0__And n>6_)______ Then
If n - i >= i And prime(n - i) Then
Print n; "="; i; "+"; n - i
End If
End If
Next i
End Sub
Private Function prime(n As Integer) As Boolean
Dim i As Integer, j As Integer, flg As Boolean
prime False
flg = True
For i = 2 To Sqr(n)
If n Mod i = 0 Then ___flg=False________
Next i
If ____flg_______ Then prime = True
End Function
Dim n As Integer, i As Integer, j As Integer
n =___TextInput.text________
For i = 3 To n - 2 Step 2
If ___((n mod 2)=0__And n>6_)______ Then
If n - i >= i And prime(n - i) Then
Print n; "="; i; "+"; n - i
End If
End If
Next i
End Sub
Private Function prime(n As Integer) As Boolean
Dim i As Integer, j As Integer, flg As Boolean
prime False
flg = True
For i = 2 To Sqr(n)
If n Mod i = 0 Then ___flg=False________
Next i
If ____flg_______ Then prime = True
End Function
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询