把项链当做字符串输进去,可以用gets

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
char a[100000];
int fj(int);
int main()
{
         gets(a);
         int len=strlen(a);
         fj(len);
         return 0;
}
int fj(int x)
{
        int m=x/2;
        if(x%2!=0)                //如果项链不能被2整除,证明项链没有被施法。。。
        {
             cout<<x;
              return x;
        }

        else
        {
             for(int i=0,j=x-1;i<m;i++,j--)
            {
                 if(a[i]!=a[j])                      //如果无法对称
                 {
                       cout<<x;
                       return x;
                 }

             }
          }
        fj(m);             //符合第一层要求,递归,继续拆分
}

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-02-17
  • 2022-12-23
  • 2021-05-30
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-17
  • 2021-10-06
  • 2022-12-23
  • 2021-10-08
  • 2021-04-06
  • 2021-10-12
  • 2021-12-30
相关资源
相似解决方案