level 6
背跃式跳远
楼主
要求:在text1 和text2 中填写两个四位数,找出其中的四位数,为什么我找出的是两者之间所有的数啊
Private Sub Command1_Click()
Dim a As Integer, b As Integer, x As Integer, y As Integer
a = Text1
b = Text2
For n = a To b
x = a Mod 100
y = a \ 100
If Fix(Sqr(x)) = Sqr(x) And prime(nx(y)) Then
List1.AddItem Str(n)
End If
Next n
End Sub
Private Function nx(y As Integer) As Integer
Dim q As Integer, p As Integer
q = y \ 10
p = y Mod 10
nx = p * 10 + q
End Function
Private Function prime(ByVal m As Integer) As Boolean
Dim a As Integer
If m = 1 Then Exit Function
For a = 2 To m - 1
If m Mod a = 0 Then
Exit Function
End If
Next a
prime = True
End Function
2011年03月17日 11点03分
1
Private Sub Command1_Click()
Dim a As Integer, b As Integer, x As Integer, y As Integer
a = Text1
b = Text2
For n = a To b
x = a Mod 100
y = a \ 100
If Fix(Sqr(x)) = Sqr(x) And prime(nx(y)) Then
List1.AddItem Str(n)
End If
Next n
End Sub
Private Function nx(y As Integer) As Integer
Dim q As Integer, p As Integer
q = y \ 10
p = y Mod 10
nx = p * 10 + q
End Function
Private Function prime(ByVal m As Integer) As Boolean
Dim a As Integer
If m = 1 Then Exit Function
For a = 2 To m - 1
If m Mod a = 0 Then
Exit Function
End If
Next a
prime = True
End Function