TheAlgorithms-C-Plus-Plus/others/Palindromeofnumber.cpp

24 lines
281 B
C++
Raw Normal View History

2019-02-10 14:40:29 +08:00
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
2019-02-10 14:40:29 +08:00
int num;
cout << "Enter number = ";
cin >> num;
2019-02-10 14:40:29 +08:00
string s1 = to_string(num);
string s2 = s1;
2019-08-21 10:10:08 +08:00
reverse(s1.begin(), s1.end());
2019-08-21 10:10:08 +08:00
if (s1 == s2)
cout << "true";
2019-02-10 14:40:29 +08:00
else
2019-08-21 10:10:08 +08:00
cout << "false";
2019-02-10 14:40:29 +08:00
return 0;
}