#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#define MAX_WORD_LENGTH 100
int main(void){
char word[MAX_WORD_LENGTH];
fgets(word, MAX_WORD_LENGTH, stdin);
int i;
for(i = 0; word[i] != '\n'; i++){
}
// count how many characters in the word/string.
int j = 0;
// if the last letter and first are not the same then it isnt a palindrome.
while(word[j] != '\n'){
if(word[j] != ' ' && word[i - 1] == ' '){
j = j - 1;
i = i - 1;
}
if((word[j] != ' ' && word[i - 1] == ' ')){
j++;
}
char c;
c = word[j];
// Checks upper/lower case letters.
if((word[j] == word[i - 1]) || (toupper(c) == word[i-1]) || ((tolower(c) == word[i-1]))){
i = i - 1;
}
j++;
}
if(i != 0){
printf("This is not a palindrome.\n");
}
else{
printf("String is a palindrome.\n");
return 1;
}
for(int x = 0; word[x + 1] != '\n';x++){
for(int y = 0; word[y] != '\n';y++){
if(word[x] == word[y] && x != y && x + 1 != y ){
printf("There exists a palindrome and an example of this is: ");
printf("%c%c%c\n", word[x], word[x + 1],word[y]);
return 1;
}
if(word[x] == word[y] && x != y && x + 1 == y ){
printf("There exists a palindrome and an example of this is: ");
printf("%c%c%c\n", word[x], word[0],word[y]);
return 1;
}
}
}
return 0;
}