//Have to work on it!!!!!!!!!!!!!!!!!!!!!//
#include<stdio.h>
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
char input[100];
char modified[100]=""; //This ll be modified form only with alphabets
cout<<"Enter text:\n";
gets(input);
int t=strlen(input);
int s=0;
for(int e=0;e<t;e++)
{
if(islower(input[e]))
{
modified[s] =input[e];
s++;
}
}
printf("\nThe modified version of the text is:");
puts(modified);
int l=strlen(modified);
for(int a=0;a<(l-1);a++)
for(int b=a+1;b<l;b++)
{
if(modified[a]==modified[b])
{
if((b-a)%2==0) //even
{
int x=(a+b)/2;
int countt=0;
for(int p=a,q=b;p<x && q>x;p++,q--)
{
if(modified[p]==modified[q])
countt++;
else if(modified[p]!=modified[q])
break;
if(countt==(b-a)/2)
{
cout<<"Palindrome:";
for(int i=a;i<=b;i++)
{
putchar(modified[i]);
}
cout<<endl;
}
}
}
else if((b-a)%2!=0) //odd
{
int y=(a+b+1)/2;
int z=(a+b-1)/2;
int count2=0;
for(int w=a,r=b;w<y && r>z ;w++,r--)
{
if(modified[w]==modified[r])
count2++;
else if(modified[w]!=modified[r])
break;
if(count2==(b-a+1)/2)
{
cout<<"Palindrome:";
for(int o=a;o<=b;o++)
{
putchar(modified[o]);
}
cout<<endl;
}
}
}
}
}
}
ICAgIAogICAgLy9IYXZlIHRvIHdvcmsgb24gaXQhISEhISEhISEhISEhISEhISEhISEvLwojaW5jbHVkZTxzdGRpby5oPgojaW5jbHVkZTxpb3N0cmVhbT4KI2luY2x1ZGU8c3RyaW5nLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CmludCBtYWluKCkKewogICAgY2hhciBpbnB1dFsxMDBdOwogICAgY2hhciBtb2RpZmllZFsxMDBdPSIiOyAgLy9UaGlzIGxsIGJlIG1vZGlmaWVkIGZvcm0gb25seSB3aXRoIGFscGhhYmV0cwogICBjb3V0PDwiRW50ZXIgdGV4dDpcbiI7CiAgICBnZXRzKGlucHV0KTsKCiAgICBpbnQgdD1zdHJsZW4oaW5wdXQpOwppbnQgcz0wOwogICAgZm9yKGludCBlPTA7ZTx0O2UrKykKICAgIHsKICAgICAgICBpZihpc2xvd2VyKGlucHV0W2VdKSkKICAgICAgICB7CiAgICAgICAgICAgIG1vZGlmaWVkW3NdID1pbnB1dFtlXTsKICAgICAgICAgICAgcysrOwogICAgICAgIH0KICAgIH0KcHJpbnRmKCJcblRoZSBtb2RpZmllZCB2ZXJzaW9uIG9mIHRoZSB0ZXh0IGlzOiIpOwogICAgcHV0cyhtb2RpZmllZCk7CgppbnQgbD1zdHJsZW4obW9kaWZpZWQpOwogICAgZm9yKGludCBhPTA7YTwobC0xKTthKyspCiAgICAgICAgZm9yKGludCBiPWErMTtiPGw7YisrKQogICAgewogICAgICAgIGlmKG1vZGlmaWVkW2FdPT1tb2RpZmllZFtiXSkKICAgICAgICB7CiAgICAgICAgICAgIGlmKChiLWEpJTI9PTApIC8vZXZlbgogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBpbnQgeD0oYStiKS8yOwogICAgICAgICAgICAgICAgaW50IGNvdW50dD0wOwogICAgICAgICAgICAgICAgZm9yKGludCBwPWEscT1iO3A8eCAmJiBxPng7cCsrLHEtLSkKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBpZihtb2RpZmllZFtwXT09bW9kaWZpZWRbcV0pCiAgICAgICAgICAgICAgICAgICAgICAgIGNvdW50dCsrOwoKICAgICAgICAgICAgICAgICAgICBlbHNlIGlmKG1vZGlmaWVkW3BdIT1tb2RpZmllZFtxXSkKICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CgogICAgICAgICAgICAgICAgICAgIGlmKGNvdW50dD09KGItYSkvMikKICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvdXQ8PCJQYWxpbmRyb21lOiI7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvcihpbnQgaT1hO2k8PWI7aSsrKQogICAgICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwdXRjaGFyKG1vZGlmaWVkW2ldKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb3V0PDxlbmRsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQoKICAgICAgICAgICAgZWxzZSBpZigoYi1hKSUyIT0wKSAvL29kZAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBpbnQgeT0oYStiKzEpLzI7CiAgICAgICAgICAgICAgICBpbnQgej0oYStiLTEpLzI7CiAgICAgICAgICAgICAgICBpbnQgY291bnQyPTA7CiAgICAgICAgICAgICAgICBmb3IoaW50IHc9YSxyPWI7dzx5ICYmIHI+eiA7dysrLHItLSkKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmKG1vZGlmaWVkW3ddPT1tb2RpZmllZFtyXSkKICAgICAgICAgICAgICAgICAgICAgICAgY291bnQyKys7CgogICAgICAgICAgICAgICAgICAgIGVsc2UgaWYobW9kaWZpZWRbd10hPW1vZGlmaWVkW3JdKQogICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKCiAgICAgICAgICAgICAgICAgICAgaWYoY291bnQyPT0oYi1hKzEpLzIpCiAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICBjb3V0PDwiUGFsaW5kcm9tZToiOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IoaW50IG89YTtvPD1iO28rKykKICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcHV0Y2hhcihtb2RpZmllZFtvXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY291dDw8ZW5kbDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICB9Cn0K