lingyun


私信TA

用户名:15210020303

访问量:71616

签 名:

喝水的鱼

等  级
排  名 26
经  验 15367
参赛次数 8
文章发表 152
年  龄 19
在职情况 学生
学  校 安徽建筑大学
专  业 电气

  自我简介:

程序爱好者

解题思路:

注意事项:

参考代码:

#include <iostream>

using namespace std;
int a[10];
int check(int n)
{
    int t=0;
    while(n>0)
    {
        a[t++]=n%10;
        //cout<<a[t-1]<<' ';
        n/=10;
    }
   //cout<<endl;
    int ok=1;
    for(int i=0;i<t/2;i++)
    {
        if(a[i]!=a[t-1-i])
        {
            ok=0;
            break;
        }
    }
    if(ok)
        return 1;
    else
        return 0;
}
int main()
{
    int L;
    cin>>L;
    int M;
    while(L--)
    {
        cin>>M;
        int ans=0;
        while(1)
        {
            if(ans>8||check(M))
                break;
            int b=M;
            int c=0;
            while(M)
            {
                c=c*10+M%10;
                M/=10;
            }
            //cout<<c<<endl;
            ans++;
            M=b+c;
        }
        //cout<<ans<<endl;
        if(ans>8)
            cout<<0<<endl;
        else
            cout<<ans<<endl;
    }
    //cout << "Hello world!" << endl;
    return 0;
}


 

0.0分

0 人评分

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

编程语言转换

万能编程问答

代码解释器

  评论区