寻找并输出11~999之间的数m,它满足m、m的平方、m的立方均为回文数。怎么用vb编程。不能调用
寻找并输出11~999之间的数m,它满足m、m的平方、m的立方均为回文数。怎么用vb编程。不能调用函数...
寻找并输出11~999之间的数m,它满足m、m的平方、m的立方均为回文数。怎么用vb编程。不能调用函数
展开
2个回答
展开全部
Private Sub Command1_Click()
For m = 11 To 999
tempYZ = 0
m1 = CStr(m)
m2 = CStr(m ^ 2)
m3 = CStr(m ^ 3)
s1 = Len(m)
s2 = Len(m ^ 2)
s3 = Len(m ^ 3)
For i = 1 To s1
If Mid(m1, i, 1) <> Mid(m1, s1 + 1 - i, 1) Then tempYZ = 1
Next
For i = 1 To s2
If Mid(m2, i, 1) <> Mid(m2, s2 + 1 - i, 1) Then tempYZ = 1
Next
For i = 1 To s3
If Mid(m3, i, 1) <> Mid(m3, s3 + 1 - i, 1) Then tempYZ = 1
Next
If tempYZ = 0 Then Print m
Next
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询