用栈实现进制转换
#include<iostream> #include<stack> using namespace std; void Conversion (int N) { int x; stack<int> s; if(N==0) { printf("%d\n",0); return ; } while(N>0) { x=N%2; s.push(x); N=N/2; } while(!s.empty()) { x=s.top(); printf("%d",x); s.pop(); } printf("\n"); } int main() { int N; while(scanf("%d",&N)!=EOF) Conversion(N); return 0; }