Option Explicit
Private Sub Command1_Click()
Dim i As Long
For i = 1 To 10000
If f1(i) = True And f1(i ^ 2) = True Then List1.AddItem i & "^" & "2" & "=" & i ^ 2
Next i
End Sub
Private Sub Command2_Click()
End
End Sub
Private Function f1(n As Long) As Boolean
Dim j As Long, m As Long
m = Len(CStr(n))
For j = 1 To m / 2
If Mid(n, j, 1) <> Mid(n, m - j + 1, 1) Then Exit Function
Next j
f1 = True
End Function
我知道你也懂一点的,我列个思路:
for i=1 to 10000
{
a=i*i
j=0
while(a/10)
{b[j]=a/10;
a=a/10;
j++;
}
a[j]=a; //接收最后一个数
//判断是否回文数
for k=0 to j/2
if(b[k] <> b[j-k])
break;
if(k==j/2)
输出b数组;
}