26 lines
391 B
C++
26 lines
391 B
C++
#include <iostream>
|
|
#include <string>
|
|
using namespace std;
|
|
|
|
bool isPalindrome(string str){
|
|
if(!str.size()){
|
|
return true;
|
|
}
|
|
|
|
if(str.front() != str.back()){
|
|
return false;
|
|
}
|
|
|
|
return isPalindrome(str.substr(1, str.size() - 2));
|
|
}
|
|
|
|
int main(){
|
|
string str;
|
|
cout<<"Enter a word: ";
|
|
cin>>str;
|
|
|
|
cout<<"The word is "<<(isPalindrome(str) ? "" : "not ")<<"palindrome."<<endl;
|
|
|
|
return 0;
|
|
}
|