// ============ not sure which one is right =========
bool is_palindrome(int x) {
int y = 1;
while(x/y >= 1) y *= 10; // gist0, cannot forgot =
y /= 10;
while(x != 0) {
int high = x / y;
int low = x % 10;
if(high != low) return false;
x /= 10; // gist1
x %= y; // gist2, note, gist1 and gist2 cannot exchange place.
}
return true;
}
// ==================
bool is_number_palindrome(int n) {
if(n < 10) return true;
int f = 1;
while(10 * f < n) f *= 10;
while(n >= 10) { // should be n >= 10 not n
int left_digit = n/f, right_digit = n%10;
if(left_digit != right_digit) return false;
n %= f;
n /= 10;
f /= 100;
}
return true;
}