#include <iostream>
#include <cstring>
char palindrome(const char* A, size_t size)
{
const char* begin = A;
const char* end = A + size - 1;
while(begin < end)
{
if(*begin++ != *end--)
{
return 'N';
}
}
return 'P';
}
int main()
{
const char* test = "madam";
std::cout << "'" << test << "' - " << palindrome(test, strlen(test)) << "\n";
return 0;
}
Comments
Leave a comment