fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int isPalindrome(int n) {
  5. char s[100] = {0};
  6. int i = 0, j = 0;
  7. while (n > 0) {
  8. s[i++] = n % 10 + 48;
  9. n /= 10;
  10. }
  11. i = 0, j = strlen(s) - 1;
  12. while (i <= j) {
  13. if (s[i++] != s[j--])
  14. return 0;
  15. }
  16. return 1;
  17. }
  18.  
  19. int main(int argc, char *argv[])
  20. {
  21. for (int i = 0; i < 100; i++) {
  22. if (isPalindrome(i * i))
  23. printf("%d\n", i);
  24. }
  25. return 0;
  26. }
  27.  
Success #stdin #stdout 0s 9424KB
stdin
Standard input is empty
stdout
0
1
2
3
11
22
26