Advertisement
fooker

binaryrep with vector output

Nov 19th, 2022
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.28 KB | None | 0 0
  1. void bitoutput(vector <ll>& d){
  2.     for (auto i:d){
  3.         cout<<i;
  4.     }
  5.     cout<<"\n";
  6. }
  7. void bitrep(ll x){
  8.     ll n=0;
  9.     vector <ll> d;
  10.     while (x>0){
  11.         n=x%2;
  12.         d.push_back(n);
  13.         x=x/2;
  14.     }
  15.     reverse(d.begin(),d.end());
  16.     bitoutput(d);
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement