题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=78
太水了
#include<iostream> #include<cstdio> using namespace std; bool is_palindrom(int x,int k) { int b[35] = {0}; while (x) { b[0]++; b[b[0]] = x % k; x /= k; } for (int i=1; i<=b[0]/2; i++) if (b[i] != b[b[0]-i+1]) return false; return true; } int main() { int x; int a[20]; while (cin>>x && x!=0) { a[0] = 0; for (int i=2; i<=16; i++) if (is_palindrom(x,i)) { a[0]++; a[a[0]] = i; } if (a[0]) { printf("Number %d is palindrom in basis",x); for (int i=1; i<=a[0]; i++) cout<<' '<<a[i]; cout<<endl; } else printf("Number %d is not a palindrom\n",x); } return 0; }