#include <iostream>
#include <cstdio>
using namespace std;
bool palindrome(string as, int i, int j){
if(i>=j) return true;
if(as[i] != as[j]) return false;
palindrome(as, i+1, j-1);
}
int main()
{
string as;
while(cin>>as){
int len = as.size()-1;
if(palindrome(as,0,len)) puts("Palindrome");
else puts("Not a Palindrome");
}
return 0;
}
Saturday, August 17, 2013
Palindrome checking using Recursion.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment