/*****************************************************
copyright (C), 2014-2015, Lighting Studio. Co., Ltd.
File name:
Author:Jerey_Jobs Version:0.1 Date:
Description:
Funcion List:
*****************************************************/
#include <stdio.h>
int main()
{
char a[100];
int i = 2,j = 2;
int max = 0,temp = 0;
int len;
int flag = 0;
printf("enter the string and the length :\n");
scanf("%s %d",a,&len);
while( i < len)
{
if(a[i] == a[i - j])
{
temp = temp + 1;
i = i + 1;
j = j + 2;
flag = 1;
}
else
{
i++;
/*if(max < temp)
{
max = temp;
j = 2;
}*/
flag = 0;
}
if(max < temp)
{
max = temp;
}
if(flag == 0)
{
j = 2;
temp = 0;
}
}
printf("the max is %d\n",2 * max + 1);
return 0;
}
找到字符串中最大的回文字串的长度
最新推荐文章于 2021-04-15 23:20:48 发布