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

24 lines
275 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-02-10 14:40:29 +08:00
reverse(s1.begin(),s1.end());
2019-02-10 14:40:29 +08:00
if(s1 == s2)
cout<<"true";
else
cout<<"false";
2019-02-10 14:40:29 +08:00
return 0;
}