VB题,输出1000—1100之间的所有质数,每行输出六个
老师要求用DoWhile来写PrivateSubCommand2_Click()Dimx%,y%,z%x=1000:y=2DoWhilex<=1100Andy<x-1x=...
老师要求用Do While来写
Private Sub Command2_Click()
Dim x%, y%, z%
x = 1000: y = 2
Do While x <= 1100 And y < x - 1
x = x + 1
If x / y <> x \ y Then
Print "x=" & x;
z = z + 1
If z Mod 6 = 0 Then Print
End If
Loop
End Sub
求大神帮助呀,= =不会写 展开
Private Sub Command2_Click()
Dim x%, y%, z%
x = 1000: y = 2
Do While x <= 1100 And y < x - 1
x = x + 1
If x / y <> x \ y Then
Print "x=" & x;
z = z + 1
If z Mod 6 = 0 Then Print
End If
Loop
End Sub
求大神帮助呀,= =不会写 展开
2个回答
展开全部
Dim x, i, a(), n, r As Integer, j As Boolean
Option Explicit
Private Sub Command1_Click()
n = -1
x = 1000
Do While x <= 1100
j = True
i = 2
Do While i < x
If Int(x / i) = x / i Then j = False
i = i + 1
Loop
If j Then
n = n + 1
ReDim Preserve a(0 To n)
a(n) = x
End If
x = x + 1
Loop
For r = 0 To n
If Int(r / 6) = r / 6 And r <> 0 Then Print vbCrLf;
Print a(r);
Next r
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询