c++二进制转换,栈存储输出

    技术2025-10-28  6

    #include<iostream> #include<stack> using namespace std; /*数制度转换,栈储存*/ int main() { stack<int>s; int n; cin>>n; while(n!=0) { s.push(n%2); n=n/2; } while(!s.empty()){ cout<<s.top(); s.pop(); } return 0; }
    Processed: 0.009, SQL: 9