fork download
  1. #include <stdio.h>
  2. #include<stdbool.h>
  3.  
  4. bool isPalindrome(int x) {
  5. if(x<0) return false;
  6. else if(x==0) return true;
  7.  
  8. int a[13];
  9. int count=1;
  10. a[0]=x%10;
  11. int temp=x/10;
  12.  
  13. while(temp!=0){
  14. a[count]=temp%10;
  15. temp/=10;
  16. count++;
  17. }
  18. count--;
  19. for (int i = 0; i < count / 2; i++) {
  20. if (a[i] != a[count - 1 - i])
  21. return false;
  22. }
  23. return true;
  24.  
  25. }
  26.  
  27. int main(){
  28. int n;
  29. scanf("%d",&n);
  30. bool a=isPalindrome(n);
  31. printf("%d",a);
  32. return 0;
  33. }
Success #stdin #stdout 0s 5320KB
stdin
121
stdout
Standard output is empty