Untitled
unknown
plain_text
a year ago
457 B
3
Indexable
#include <iostream>
#include <string>
using namespace std;
bool isPalindrome(string &str, int start, int end){
if (start >= end)return true;
if (str[start] != str[end] )return false;
return isPalindrome(str, start + 1, end - 1);
}
int main() {
int n;
cin>>n;
string str = to_string(n);
if (isPalindrome(str, 0, str.length() - 1))
cout<<"Palindrome: "<<endl;
else
cout<<"Not a palindrome"<<endl;
return 0;
}Editor is loading...
Leave a Comment