fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <map>
  4.  
  5. using namespace std;
  6.  
  7. unsigned IsPalindrome(unsigned num)
  8. {
  9. unsigned temp=num,num_2=0;
  10. while(temp)
  11. {
  12. num_2=num_2*10+temp%10;
  13. temp=temp/10;
  14. }
  15. if(num_2 == num)
  16. {
  17. return 1;
  18. }
  19. else
  20. {
  21. return 0;
  22. }
  23. }
  24.  
  25. int main(void)
  26. {
  27. if(IsPalindrome(1221) == 1)
  28. {
  29. cout<<"Yes"<<endl;
  30. }
  31. else
  32. {
  33. cout<<"No"<<endl;
  34. }
  35.  
  36. if(IsPalindrome(1223) == 1)
  37. {
  38. cout<<"Yes"<<endl;
  39. }
  40. else
  41. {
  42. cout<<"No"<<endl;
  43. }
  44.  
  45. if(IsPalindrome(12321) == 1)
  46. {
  47. cout<<"Yes"<<endl;
  48. }
  49. else
  50. {
  51. cout<<"No"<<endl;
  52. }
  53.  
  54. if(IsPalindrome(12322) == 1)
  55. {
  56. cout<<"Yes"<<endl;
  57. }
  58. else
  59. {
  60. cout<<"No"<<endl;
  61. }
  62.  
  63. return 0;
  64. }
  65.  
Success #stdin #stdout 0.01s 2724KB
stdin
Standard input is empty
stdout
Yes
No
Yes
No