标签:
#include <stdio.h>
#include <string.h>
int pal(char *str)
{
int len = strlen(str);
int l, r;
int ans = len;
for(int i=0; i<len; i++)
{
l = i-1; r = i+1;
while(l >= 0 && r < len && str[l] == str[r])
{l--; r++; ans++;}
l = i; r = i+1;
while(l >= 0 && r < len && str[l] == str[r])
{l--; r++; ans++;}
}
return ans;
}
int main()
{
//freopen("read.txt", "r", stdin);
char str[10000];
while(~scanf("%s", str))
{
printf("%d\n", pal(str));
}
return 0;
}
标签:
原文地址:http://www.cnblogs.com/sober-reflection/p/9621dbff976aa34b507a2ed33e7178a4.html