Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include <vector>
- #include <cstring>
- using namespace std;
- void print_binary(int x) {
- string s = "";
- while(x > 0) {
- s += (x % 2) + '0';
- x /= 2;
- }
- reverse(s.begin(), s.end());
- cout << s << endl;
- }
- int main() {
- int n;
- cin >> n;
- print_binary(n);
- return 0;
- }
- // 1011000101110
- // 1011000101110
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement