这道计算机VB编程题怎么写?
2个回答
展开全部
Option Explicit
Private Sub Command1_Click()
Dim i As Integer
Dim n1 As Integer, n2 As Integer
For i = 11 To 4999
n1 = i Mod 10
n2 = (i Mod 100 - n1) / 10
If isAlone(i) And n2 > n1 Then
Debug.Print i
End If
Next
End Sub
Function isAlone(n As Integer) As Boolean
Dim i As Integer
For i = 3 To n - 1
If n Mod i = 0 Then
isAlone = False
Exit Function
End If
Next
isAlone = True
End Function
Private Sub Command1_Click()
Dim i As Integer
Dim n1 As Integer, n2 As Integer
For i = 11 To 4999
n1 = i Mod 10
n2 = (i Mod 100 - n1) / 10
If isAlone(i) And n2 > n1 Then
Debug.Print i
End If
Next
End Sub
Function isAlone(n As Integer) As Boolean
Dim i As Integer
For i = 3 To n - 1
If n Mod i = 0 Then
isAlone = False
Exit Function
End If
Next
isAlone = True
End Function
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询