mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-04-04 02:59:43 +08:00
Merge pull request #155 from gopikrishnanrmg/master
Added and algorithm to check if a number is palindrome
This commit is contained in:
23
Palindromeofnumber.cpp
Normal file
23
Palindromeofnumber.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main()
|
||||
{
|
||||
int num;
|
||||
cout << "Enter number = ";
|
||||
cin >> num;
|
||||
|
||||
string s1 = to_string(num);
|
||||
string s2 = s1;
|
||||
|
||||
reverse(s1.begin(),s1.end());
|
||||
|
||||
if(s1 == s2)
|
||||
cout<<"true";
|
||||
else
|
||||
cout<<"false";
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user