用vb编程:输出100-200之间的所有素数,并将这些数求和,求出结果存入所给变量su
1个回答
展开全部
Private Sub Command1_Click()
Dim i As Integer, j As Integer, k As Integer, su As Integer
For i = 100 To 300
For j = 2 To Int(Sqr(i))
If i Mod j = 0 Then
Exit For
End If
Next
If j > Int(Sqr(i)) Then
su = su + i
If k Mod 10 = 0 Then Print
Print Format(i, "@@@@");
k = k + 1
End If
Next
MsgBox su
End Sub
Dim i As Integer, j As Integer, k As Integer, su As Integer
For i = 100 To 300
For j = 2 To Int(Sqr(i))
If i Mod j = 0 Then
Exit For
End If
Next
If j > Int(Sqr(i)) Then
su = su + i
If k Mod 10 = 0 Then Print
Print Format(i, "@@@@");
k = k + 1
End If
Next
MsgBox su
End Sub
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询