PCLP2/lab07/03.cpp

26 lines
391 B
C++
Raw Normal View History

2020-05-01 14:58:05 +00:00
#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;
}