1、题目
正整数n若是它平方数的尾部,则称n为同购数。例如6是36的同构数
找出1000以内的
2、源码
1: #include <stdio.h>
2:
3: int func(int i)
4: {
5: int j;
6:
7: for(j = 10; j < 1000; j = j * 10)
8: {
9: if(i / j == 0) // 获得i的位数
10: break;
11: }
12:
13: if((i * i) % j == i)
14: return 1;
15: else
16: return 0;
17: }
18: void gettonggou()
19: {
20: int i;
21:
22: for(i = 1; i <= 1000; i++)
23: {
24: if(func(i))
25: printf("%d ", i);
26: }
27: }
28:
29: int main()
30: {
31: printf("The Tonggoushu bellow 1000 are\n");
32: gettonggou();
33: printf("\n");
34: }