自守数

自守数是指一个数的平方的尾数等于该数自身的自然数,求一定范围的自守数

#include <stdio.h>
#include <math.h>

int main(void)
{
        int i,n,counts,temp;

        for(i=0;i<=10000;i++)
        {
                n = i * i;
                counts = 0;
                temp = 0;
                while(temp<i)
                {
                        temp += n%10*(int)pow(10,counts);
                        if(i == temp) {
                                printf("%d\n",i);
                                break;
                        }
                        n = n/10;
                        ++counts;
                }
        }

        return 0;
}