cs161AWinter2024/palfor.cpp

26 lines
382 B
C++

#include <iostream>
#include <string>
using namespace std;
int main(){
string str;
cout << "Enter a word" << endl;
cin >> str;
int l = str.length();
bool isPal = true;
for(int i = 0; i < l; i++){
if(str[i] != str[(l - 1) - i]){
isPal = false;
}
}
if(isPal){
cout << "palindrome" << endl;
}
else{
cout << "not palindrome" << endl;
}
}