【LeetCode】9. Palindrome Number

Determine whether an integer is a palindrome. Do this without extra space.

题意:确定一个数字是否回文

思路:把数字倒过来,与原数字对比

这是leetcode中做的最顺利的一个题了,一次ac,当然是因为这个题太简单了。。。

 1 bool isPalindrome(int x) {
 2     if(x<0)
 3         return 0;
 4  int x2=x;
 5  int a;
 6  int mirror=0;
 7  while(x2){
 8      a=x2%10;
 9      mirror=mirror*10+a;
10      x2/=10;
11  }
12  if(mirror==x)
13  return 1;
14  else
15  return 0;
16 }
原文地址:https://www.cnblogs.com/fcyworld/p/6198597.html