求帮助,非常需要,不 (hao) 胜(ren) 感 (ping)激(an)。

 求帮助,非常需要,不 (hao) 胜(ren) 感 (ping)激(an)。

img

判断是回文分割之后再判断是不是回文
你题目的解答代码如下:

#include<stdio.h>
#include <string.h>

int testPalindrome(char s[], int a,int b)
{
    while (a<b)
    {
        if (s[a]!=s[b])
            return 0;
        a++;
        b--;
    }
    return 1;
}

int main()
{
    int l, count=1;
    char s[1002];
    gets(s);
    l = strlen(s);
    while (l>1)
    {
        if(testPalindrome(s,0,l-1))
        {
            l /= 2;
            count *= 2;
        }
        else
            break;
    }
    printf("%d\n", count);
    return 0;
}

img

如有帮助,请点击我的回答下方的【采纳该答案】按钮帮忙采纳下,谢谢!

img

您好,我是有问必答小助手,您的问题已经有小伙伴帮您解答,感谢您对有问必答的支持与关注!
PS:问答VIP年卡 【限时加赠:IT技术图书免费领】,了解详情>>> https://vip.csdn.net/askvip?utm_source=1146287632