#include <iostream> #include<cmath> #include<ctime> #include<string> #include <iomanip> #include <fstream> using namespace std; int main() { int num, reversedInteger = 0, remainder, originalInteger; cin >> num; originalInteger = num; for (; num != 0; num /= 10) { remainder = num % 10; reversedInteger = reversedInteger * 10 + remainder; } if (originalInteger == reversedInteger) cout << originalInteger << " is a palindrome."; else cout << originalInteger << " is not a palindrome."; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter