写了代码之后再列表框中输出不出来 10
PrivateSubForm_Activate()Dimi,j,nAsInteger,flagAsBooleanflag=FalseForn=6To100Step2For...
Private Sub Form_Activate()
Dim i, j, n As Integer, flag As Boolean
flag = False
For n = 6 To 100 Step 2
For i = 2 To n / 2
For j = 2 To Sqr(i)
If i Mod j = 0 Then
flag = True
End If
Next j
For j = 2 To Sqr(n - i)
If i Mod j = 0 Then
flag = True
End If
Next j
If flag = False Then
List1.AddItem n & "=" & i & "+" & (n - i)
Exit For
End If
Next i
Next n
End Sub 展开
Dim i, j, n As Integer, flag As Boolean
flag = False
For n = 6 To 100 Step 2
For i = 2 To n / 2
For j = 2 To Sqr(i)
If i Mod j = 0 Then
flag = True
End If
Next j
For j = 2 To Sqr(n - i)
If i Mod j = 0 Then
flag = True
End If
Next j
If flag = False Then
List1.AddItem n & "=" & i & "+" & (n - i)
Exit For
End If
Next i
Next n
End Sub 展开
1个回答
展开全部
你是要干嘛?验证两个数相加等于某个数?如果你把“If flag = False”改为“If flag = True”则列表框会出现内容。不出现是因为你根本无法使得 flag = False
追问
目的是在列表框中输出 100以内歌德巴赫猜想 就是一个偶数可以分解成两个素数的和 拜托帮忙看一下(⊙_⊙)
追答
This is my Goldbach's conjecture, .NET version. You can use it as reference.
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询