找出11——999之间的所有三重回文数字,就是a的a,a平方,a立方都是回文
1: #include "stdio.h"
2:
3: long reverse(long i)
4: { /*求i 的倒置数*/
5: long m, j = 0;
6: m = i;
7:
8: while(m) {
9: j = j * 10 + m % 10;
10: m = m / 10;
11: }
12:
13: return j; /*返回i的倒置数j*/
14: }
15:
16: long isCircle(long n)
17: { /*函数isCircle 判断n是否是回文数字*/
18: long m;
19: m = reverse(n);
20:
21: if(m == n)
22: return 1;
23: else
24: return 0;
25: }
26:
27: void palindrome(long low, long high)
28: {
29: long i;
30:
31: for(i = low; i <= high; i++)
32: {
33: if(isCircle(i) && isCircle(i * i) && isCircle(i * i * i))
34: printf("%d ", i);
35: }
36: }
37:
38: int main()
39: {
40: printf("The palindrome numbers between 11~999 are\n");
41: palindrome(11, 999);
42: return 0;
43: }