Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

#include<stdio.

h>
#include<string.h>

#define MIN(a,b) (a)<(b) ? (a):(b)


char siri[300];
char sirn[1000];

int pal(char *s,int n)


{
int i = 0;
while(i<=n/2 && s[i] == s[n-i-1])
i++;

if(i>n/2) return 1;
else return 0;
}
int n,r;
int main()
{
freopen("palc.in","r",stdin);
freopen("palc.out","w",stdout);

while(scanf("%c",&siri[n]) != -1 && siri[n] != '\n'&&siri[n]!='\r')


n++;
siri[n]='\0';
n = strlen(siri);
strcpy(sirn,siri);
strcpy(sirn+n,siri);

r=-1;
for(int i=0;i<n;i++)
{
if(pal(sirn+i,n))
r= MIN(i,n-i);
}
printf("%d",r);
fclose(stdin); fclose(stdout);
return 0;
}

You might also like