每行有一个数字n(0<=n<=10^8),表示要求的二进制串。
输出共T行。每行输出求得的二进制串。
10111
1 #include <iostream> 2 #include <algorithm> 3 #include <string> 4 #include <cstring> 5 #include <stack> 6 using namespace std; 7 int n; 8 int main() 9 { 10 while(cin>>n){ 11 stack<int> s; 12 while(n){ 13 s.push(n%2); 14 n/=2; 15 } 16 while(s.size()>0){ 17 cout<<s.top(); 18 s.pop(); 19 } 20 cout<<endl; 21 } 22 return 0; 23 }
原文:https://www.cnblogs.com/shixinzei/p/10683555.html