回文数

```

#define _CRT_SECURE_NO_WARNINGS

#include<stdio.h>

#define N 10

void main()

{

    int n[N];

    int i, j, k, s = 0, flag, a;

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

    {

        a = i * i;flag = 1;s = 1;

        for (j = 10; a / j != 0; s++, j *= 10);

        //for (k = 0; a != 0; k++)    

        //{

        //  n[k] = a % 10;

        //  a /= 10;

        //}

        for (k = 0; j != 1; k++)

        {

             j /= 10;

             n[k] = a / j % 10;

        }

             for (j = 0; j < s / 2; j++)

             if (n[j] != n[s - j - 1]) {

                 flag = 0;

                 break;

             }

        if (flag == 1)printf("%d ", i);

    }

}

```

 

posted @ 2023-05-22 20:39  258333  阅读(8)  评论(0编辑  收藏  举报