Write a function to check whether an integer is a palindrome without using arrays.
Anónimo
Just reverse the number and compare with the original one. Note, that it actually depends on the radix base, whether the number is a palindrome (in that base) or not. bool is_palindrome(const unsigned n, const unsigned radix = 10) { if (radix <= 0) return false; unsigned x = n; unsigned reverse = 0; while (x != 0) { reverse *= radix; reverse += x % radix; x /= radix; } // 0 is considered a palindrome here // (reads the same way from both sides after all) return n == reverse; }