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 num_2=0;
  10. while(num)
  11. {
  12. num_2=num_2*10+num%10;
  13. num=num/10;
  14. }
  15. return num_2;
  16. }
  17.  
  18. int main(void)
  19. {
  20. unsigned num=1221;
  21. if(IsPalindrome(num) == num)
  22. {
  23. cout<<"Yes"<<endl;
  24. }
  25. else
  26. {
  27. cout<<"No"<<endl;
  28. }
  29. num=1223;
  30. if(IsPalindrome(num) == num)
  31. {
  32. cout<<"Yes"<<endl;
  33. }
  34. else
  35. {
  36. cout<<"No"<<endl;
  37. }
  38. num=12321;
  39. if(IsPalindrome(num) == num)
  40. {
  41. cout<<"Yes"<<endl;
  42. }
  43. else
  44. {
  45. cout<<"No"<<endl;
  46. }
  47. num=12322;
  48. if(IsPalindrome(num) == num)
  49. {
  50. cout<<"Yes"<<endl;
  51. }
  52. else
  53. {
  54. cout<<"No"<<endl;
  55. }
  56.  
  57. return 0;
  58. }
  59.  
Success #stdin #stdout 0.01s 2724KB
stdin
Standard input is empty
stdout
Yes
No
Yes
No