功能:找出1至n之间同构数的个数
输入:
int n:查找1至n之间的全部同构数
返回:
int:1至n之间同构数的个数
输入:
int n:查找1至n之间的全部同构数
返回:
int:1至n之间同构数的个数
int SearchSameConstructNum(int n)
{
/*在这里实现功能*/
int curNum=0;
int temp = 0;
int sqNum = 0;
int cnt=0;
if (n<1)
{
return -1;
}
for (curNum=1;curNum<=n;curNum++)
{
temp = curNum;
sqNum = temp*temp;
while(1)
{
if ((temp%10)==(sqNum%10))
{
temp = temp/10;
sqNum = sqNum/10;
if (temp==0)
{
cnt++;
break;
}
}
else
{
break;
}
}
}
return cnt;
}
int main()
{
int n = 65536;
int cnt = 0;
cnt = SearchSameConstructNum(n);
return 0;
}