Advertisement
Josif_tepe

Untitled

Feb 16th, 2022
830
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.30 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4. int main()
  5. {
  6.     int n;
  7.     cin >> n;
  8.     string binary = "";
  9.     while(n > 0) {
  10.         binary += (n % 2) + '0';
  11.         n /= 2;
  12.     }
  13.     reverse(binary.begin(), binary.end());
  14.     cout << binary << endl;
  15.    
  16.     return 0;
  17. }
  18.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement