bshy.net
当前位置:首页>>关于VB题,输出1000—1100之间的所有质数,每行输出六个的资料>>

VB题,输出1000—1100之间的所有质数,每行输出六个

'输出 1000—1100 之间的所有质数,每行输出六个 Private Sub Command2_Click() Dim x%, z% Dim m%, n% x = 1000 z = 0 Do While x 2 If x Mod m = 0 Then n = n + 1 m = m - 1 Loop If n = 0 Then Print x; z = z + 1 If z Mod 6 = 0 Then Print ...

dim i as integer ,n as integer for i=1000 to 1100 if f(i)=true then print i n=n+1 if n=6 then print n=0 end if end if next i private function f(t as integer)as boolean for i=2 to t-1 if t mod i=0 then f=true else f=false end if...

'新建一个工程。把Form窗口拉长一点。在代码窗口写入如下代码:Option ExplicitPrivate Function IsPrimeNumber(ByVal Number As Integer) As Boolean Dim i As Integer For i = 2 To Number - 1 If Number Mod i = 0 Then IsPrimeNumber = Fals...

Private Sub Command1_Click() Dim a% a = 1000 '从1000开始找 Do a = a + 1 If isprime(a) Then '调用isprime()函数过程判断a是否素数 Text1.Text = Text1.Text & " " & a End If Loop Until a > 1100 End Sub '下面这个函数是用来判别一个数是...

Me.Cls Dim x, i, j, k As Single x = 100For i = 2 To x k = 0 For j = 2 To sqrt(i) If i Mod j = 0 Then k = k + 1 :exit for Next j If k = 1 Then Print i Next i

Private Sub Form_Click() '点击窗体运行Dim x As Integer, y As IntegerFor x = 500 To 1000 '500到1000之间 For y = 2 To Sqr(x) '如果这个数能被2到自己的平方根整除, If x Mod y = 0 Then Exit For '就说明不是素数,强行退出循环 Next y I...

Private Sub Command1_Click() Dim i As Integer For i = 1 To 1000 If ss(i) Then Print i; k = k + 1 If k Mod 10 = 0 Then Print End If Next i Print: Print End Sub Function ss(x As Integer) As Boolean ss = False For i = 2 To Sqr(x) ...

Private Sub Command1_Click() Dim i As Integer For i = 1 To 1000 If ss(i) Then Print i; k = k + 1 If k Mod 10 = 0 Then Print End If Next i Print: Print End Sub Function ss(x As Integer) As Boolean ss = False For i = 2 To Sqr(x) ...

Private Sub Form_Click()Dim i As Integer, n As IntegerDim j As Integer, m As Integern = 1000For i = 2 To n For j = 2 To Int(Sqr(i)) If i Mod j = 0 Then Exit For Next If j > Int(Sqr(i)) Then If m Mod 4 = 0 Then Print m = m + 1 P...

Private Sub Form_Click()Dim i As Integer, j As Integer, n As LongFor i = 1000 To 2000 For j = 2 To Int(Sqr(i)) If i Mod j = 0 Then Exit For Next If j > Int(Sqr(i)) Then n = n + iNextPrint nEnd Sub

网站首页 | 网站地图
All rights reserved Powered by www.bshy.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com