要给定范围啊~
#include <stdio.h> // 如果是回文数则返回1否则返回0 int is_palindrome(int n) { int i, j, k = 0, x = 1, y = n, z = 0; while(y /= 10) { x *= 10; } for(i = x, j = 1; i > j; i /= 10, j *= 10) { z++; if(n / i % 10 == n / j % 10) { k++; } } if(k == z) return 1; return 0; } void print_palindrome(int range) { printf("0 to %d:\n", range); int i = 0; while(i < range) { if(is_palindrome(i)) { printf("%d\n", i); } i++; } } int main(void) { print_palindrome(10000); return 0; } /* Output: 1 to 2293508: 0 1 2 3 4 5 6 7 8 9 11 22 33 44 55 66 77 88 99 101 111 121 131 141 ... 8118 8228 8338 8448 8558 8668 8778 8888 8998 9009 9119 9229 9339 9449 9559 9669 9779 9889 9999 Process returned 0 (0x0) execution time : 0.172 s Press any key to continue. */这样就可以了。