#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(void)
{
char s[1000];
int i,i2=1,j,k,l,len,len2;
printf("Please input your string to calculate the longest palindromes in your string!\n");
gets(s);
len=strlen(s);
for(i=0;i<len;i++)<br /> {
for(j=0;j<=i;j++)
{
k=0;
len2=len-i;
while(k<=(len2-2)/2)
{
if(s[j+k]!=s[len2-1+j-k])
{
break;
}
k++;
}
if(k>(len2-2)/2)
{
i2=0;
for(l=0;l<=len2-1;l++)
{
printf("%c",s[j+l]);
}
printf("\n");
}
}
if(!(i2))
break;
}
system("pause");
return 0;
}
幹
然後去DEMO還沒有過
肏!
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.114.218.84