#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int ishuiwen(char *p)
{
int i = strlen(p);
for(int j=0;j<=i/2;j++)
{
if(p[j] !=p[i-j-1])
{
return 0;
}
}
return 1;
}
char * getSubString(char *p, int m, int slen)
{
char *buf = new char[strlen(p) + 1];
int count = 0;
for(int k=m;p[k]!=' '&& count<slen;k++)
{
buf[count++] = p[k];
}
buf[count] = ' ';
return buf;
}
int gerlongStr(char *p)
{
int len = strlen(p);
int i=0;
int flag = 0;
while(i<=len)
{
int slen = len-i;
for(int j=0;j<=i;j++)
{
char *buf = getSubString(p, j, slen);
//printf("%s
", buf);
if(ishuiwen(buf)==1)
{
printf(buf);
printf("
");
flag =1;
}
free(buf);
}
if(flag)
return flag;
i++;
}
return flag;
}
int main()
{
gerlongStr("helloworldlrowdfsg");
return 0;
}