Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <cstring>
- #include <algorithm>
- #include <stack>
- #include <fstream>
- using namespace std;
- typedef long long ll;
- void to_binary(int x) {
- string r = "";
- while(x) {
- r += (x % 2) + '0';
- x /= 2;
- }
- reverse(r.begin(), r.end());
- cout << r << endl;
- }
- int main() {
- int number = 21;
- to_binary(number);
- number |= (1 << 1);
- cout << number << endl;
- to_binary(number);
- number |= (1 << 3);
- to_binary(number);
- cout << number << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement