mengxin


私信TA

用户名:1000001

访问量:6604

签 名:

等  级
排  名 489
经  验 4504
参赛次数 0
文章发表 73
年  龄 0
在职情况 学生
学  校
专  业

  自我简介:

参考代码:

#include <stdio.h>
#include <stdlib.h>
int huiwen(int n)//回文判断
{
    int count=0;
    int m=n;
    while(m)
    {
        count*=10;
        count+=m%10;
        m/=10;
    }
    if(n==count)
        return 1;
    else
        return 0;
}
int addhuiwen(int n)//回文数加法
{
    int count=0;
    int m=n;
    while(m)
    {
        count*=10;
        count+=m%10;
        m/=10;
    }
    return n+count;
}
int main()
{
    int n;
    int x;
    scanf("%d",&n);//组数
    for(int i=0;i<n;i++)
    {
        scanf("%d",&x);//判断数
        int count=0;//步骤
        if(huiwen(x)==1)
            {
                count++;
                printf("%d\n",count);
            }
        else
        {
            while(huiwen(x)==0&&count<=8)
        {
            x=addhuiwen(x);
            count++;
        }
        if(count>8)//大于8步
            printf("0\n");
        else//小于8步
            printf("%d\n",count);
        }

    }
    return 0;
 }

 

0.0分

0 人评分

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

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

代码解释器

代码纠错

SQL生成与解释

  评论区