#include <stdio.h> #include <stdlib.h> int main(int argc, char * argv[]){ int m[16], n, i, t, count = 0; long unsigned a, k; for(n=1; n<256; n++) { k=0; t=1; a=n*n; for(i=0; a!=0; i++) { m[i] = a%10; a /= 10; } for(; i>0; i--) { k+=m[i-1]*t; t*=10; } if(k==a) printf("%d\n", n); } } /* #define maxn 105 int a[maxn]; int main(int argc, char *argv[]) { int n, i; scanf("%d", &n); for(i=1; i<=n; i++){ int s = i*i; int k = 0; int j; for(j=0;s!=0; j++) { a[j] = s%10; s /= 10; k++; } if(a[j] == a[k-j+1]) printf("%d\n", ); } return 0; } */
原文地址:http://blog.csdn.net/orangeisnotapple/article/details/44816215