分,共12分.) 一个自然数倒过来读仍是这个数,就叫回文数,有些回文数还是素数,就叫回文式素数,如9323Function hw(m As Long) As BooleanDim a As Integer,b As Integer,c As Integer,d As Integera = Left(m,1):b = Mid(m,2,1)c
来源:学生作业帮助网 编辑:作业帮 时间:2024/05/14 05:13:56
![分,共12分.) 一个自然数倒过来读仍是这个数,就叫回文数,有些回文数还是素数,就叫回文式素数,如9323Function hw(m As Long) As BooleanDim a As Integer,b As Integer,c As Integer,d As Integera = Left(m,1):b = Mid(m,2,1)c](/uploads/image/z/1967536-64-6.jpg?t=%E5%88%86%2C%E5%85%B112%E5%88%86.%EF%BC%89+%E4%B8%80%E4%B8%AA%E8%87%AA%E7%84%B6%E6%95%B0%E5%80%92%E8%BF%87%E6%9D%A5%E8%AF%BB%E4%BB%8D%E6%98%AF%E8%BF%99%E4%B8%AA%E6%95%B0%2C%E5%B0%B1%E5%8F%AB%E5%9B%9E%E6%96%87%E6%95%B0%2C%E6%9C%89%E4%BA%9B%E5%9B%9E%E6%96%87%E6%95%B0%E8%BF%98%E6%98%AF%E7%B4%A0%E6%95%B0%2C%E5%B0%B1%E5%8F%AB%E5%9B%9E%E6%96%87%E5%BC%8F%E7%B4%A0%E6%95%B0%2C%E5%A6%829323Function+hw%28m+As+Long%29+As+BooleanDim+a+As+Integer%2Cb+As+Integer%2Cc+As+Integer%2Cd+As+Integera+%3D+Left%28m%2C1%29%3Ab+%3D+Mid%28m%2C2%2C1%29c)
分,共12分.) 一个自然数倒过来读仍是这个数,就叫回文数,有些回文数还是素数,就叫回文式素数,如9323Function hw(m As Long) As BooleanDim a As Integer,b As Integer,c As Integer,d As Integera = Left(m,1):b = Mid(m,2,1)c
分,共12分.) 一个自然数倒过来读仍是这个数,就叫回文数,有些回文数还是素数,就叫回文式素数,如9323
Function hw(m As Long) As Boolean
Dim a As Integer,b As Integer,c As Integer,d As Integer
a = Left(m,1):b = Mid(m,2,1)
c = _____________________
d = _____________________
hw = IIf(a = d And b = c,True,False)
End Function
Function ss(m As Long) As Boolean
Dim k As Long,i As Long,f As Boolean
f=True
k = Sqr(m)
For i = 2 To k
If _____________________ Then
f = False
Exit For
End If
Next i
________________
End Function
Private Sub Command1_Click()
Dim m As Long,n As Integer
For m = 10000 To 99999
If _____________________________ Then
Print Tab((n Mod 10) * 8 + 1); m;
n = n + 1
End If
Next m
End Sub
Mid(m,4,1) Right(m,1) 注意:只要能取出第四、五位即可得分
m mod i=0(只要能判断整除即可)
ss=f ss(m) hw(m)(只写ss及hw不得分,如果写了True但写错了扣1分)
分,共12分.) 一个自然数倒过来读仍是这个数,就叫回文数,有些回文数还是素数,就叫回文式素数,如9323Function hw(m As Long) As BooleanDim a As Integer,b As Integer,c As Integer,d As Integera = Left(m,1):b = Mid(m,2,1)c
问题补充:
Function hw(m As Long) As Boolean
Dim a As Integer,b As Integer,c As Integer,d As Integer
a = Left(m,1):b = Mid(m,2,1)
c = mid(m,4,1)
d = right(m,1)
hw = IIf(a = d And b = c,True,False)
End Function
Function ss(m As Long) As Boolean
Dim k As Long,i As Long,f As Boolean
f=True
k = Sqr(m)
For i = 2 To k
If m mod i =0 Then
f = False
Exit For
End If
Next i
ss=f
End Function
Private Sub Command1_Click()
Dim m As Long,n As Integer
For m = 10000 To 99999
If ss(m) and hw(m) Then
Print Tab((n Mod 10) * 8 + 1); m;
n = n + 1
End If
Next m
End Sub