#include <iostream> // required for cout, and cin
// returns the length of a c style string
int stringLength(char *input)
{
int i = 0;
// Is this a null terminating character
while (input[i])
{
// No, check the next character
i++;
}
return i;
}
int main()
{
// Get input from the user.
char input[100];
std::cin >> input;
// Calculate the length of the input
int length = stringLength(input);
// At position length is the null terminating character,
// the last character is actually at position len - 1
int lastIndex = length - 1;
// Stores whether of not we found a palindrome
bool isPalindrome = true;
// Loop through the string checking if the first character is equal to
// the last, second to second last etc...
for (int i = lastIndex; i >= length/2; i--)
{
// Check the palindrome condition
if (input[i] != input[lastIndex - i])
{
isPalindrome = false;
break;
}
}
// Output the result
if (isPalindrome)
{
std::cout << "Palindrome" << std::endl;
}
else
{
std::cout << "Not palindrome" << std::endl;
}
return 0;
}