编写VB程序:找出10~100范围内的所有素数,并将这些素数显示在窗体上
2个回答
展开全部
Dim x As Integer, i As Integer
Dim y As Integer
For x = 10 To 100
y = Int(Sqr(x)) + 1
For i = 2 To y
If x Mod i = 0 Then
Exit For
End If
Next i
If i = y + 1 Then
Print x;
End If
Next x
Dim y As Integer
For x = 10 To 100
y = Int(Sqr(x)) + 1
For i = 2 To y
If x Mod i = 0 Then
Exit For
End If
Next i
If i = y + 1 Then
Print x;
End If
Next x
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Option Explicit
Private Sub Form_Load()
Dim i As Long, j As Long, k As Long
Show
For i = 10 To 100
k = k + 1
For j = 2 To i - 1
If i Mod j = 0 Then Exit For
Next
If k = 50 Then Print: k = 0
If j > i - 1 Then Print j;
Next
End Sub
Private Sub Form_Load()
Dim i As Long, j As Long, k As Long
Show
For i = 10 To 100
k = k + 1
For j = 2 To i - 1
If i Mod j = 0 Then Exit For
Next
If k = 50 Then Print: k = 0
If j > i - 1 Then Print j;
Next
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询