题解 | #二进制数#
二进制数
https://www.nowcoder.com/practice/103dd589fed14457a673c613d8de3841
#include <iostream> #include <stack> using namespace std; stack<int> s; int main() { int x; while(cin>>x){ while(!s.empty()) s.pop(); while(x>0){ s.push(x%2); x/=2; } while(!s.empty()){ cout<<s.top(); s.pop(); } cout<<endl; } }