000928


私信TA

用户名:qiubi

访问量:1055

签 名:

等  级
排  名 10069
经  验 1053
参赛次数 0
文章发表 5
年  龄 0
在职情况 学生
学  校 广东工业大学
专  业

  自我简介:

TA的其他文章

解题思路:

注意事项:

参考代码:

#include <stdio.h>

#include <stdlib.h>

#include <string.h>

 

int findchar(char a[],int i,int j)

{

    int len,judge=0;

    len=j-i;

    if(len%2==1)

    {

        for(int t=0; t<(len+1)/2; t++)

        {

            if(a[i+t]!=a[j-t])

            {

                return 0;

            }

        }

        return (j-i+1);

    }

    else

    {

        for(int t=0; t<len/2; t++)

        {

            if(a[i+t]!=a[j-t])

            {

                return 0;

            }

        }

    }

    return (j-i+1);

   

}

int main()

{

    int max=0,len;

    int i=0;

    char a[1024];

    char *b[100];

    while(scanf("%[^\n]",a)!=EOF){

    getchar();

    len=strlen(a);

    b[i]=(char*)malloc(sizeof(char)*len);

    strcpy(b[i],a);

    i++;

}

    int len_str;

    for(int m=0;m<i;m++){

    len_str=strlen(b[m]);

    for(int j=0;j<len_str;j++){

for(int k=j;k<len_str;k++){

if((findchar(b[m],j,k)>max)){

    max=findchar(b[m],j,k);

}

   

}

}

printf("%d\n",max);

max=0;

}


return 0;

}


 

0.0分

2 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区