PCLP2/lab07/03.cpp
Fándly Gergő 4a6331088a chore: Lab07
2020-05-01 17:58:05 +03:00

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;
}