紫竹


私信TA

用户名:urnachan

访问量:29033

签 名:

等  级
排  名 304
经  验 5441
参赛次数 0
文章发表 72
年  龄 0
在职情况 学生
学  校 合肥工业大学
专  业

  自我简介:

TA的其他文章

#include "stdafx.h"                          //答案又不对!!  暂时没找到原因          

int reverse(int n)                              //数据反置

{

     int a[20],i=0,j,t=1;

     long int s = 0;

     do

     {

     a[i++] = n % 10;

     n /= 10;

     } while (n);

     j = i;

     for (i = j-1; i >=0; i--)

     {

     s += t*a[i];

     t *= 10;

     }

     return s;

}

int fun(int n)                                     //判断是否为回文

{

     int a[20], i = 0, j, t = 1;

     do

     {

     a[i++] = n % 10;

     n /= 10;

     } while (n);

     j = i;

     for (i = 0; i <= (j + 1) / 2; i++)

     {

     if (a[i] == a[j - 1 - i])

     return 1;

     else

     return 0;

     }


}

int main()

{

     int L,n[100],i=0,j,count=1;

     scanf("%d", &L);

     while (L--)

     {

     scanf("%d", &n[i++]);

     }

     j = i;

     for (i = 0; i < j; i++)

     {

     while (count)

     {

     if (count <= 8)

     {

     if (fun(n[i] + reverse(n[i])) == 1)

     {

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

     break;

     }

     else

     {

     count++;

     n[i] = n[i] + reverse(n[i]);

     }

     }

     else

     {

     printf("0\n");

     break;

     }

    

     }

     }

     return 0;

}


 

0.0分

0 人评分

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

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区