Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <iostream>
- using namespace std;
- int main(){
- int a = 3; // 0...0 0011
- int b = 5; // 0...0 0101
- int c = a & b; // 0...0 0001
- int d = a | b; // 0...0 0111
- int e = ~ a; // 1...1 1100
- int f = a ^ b; // 0...0 0110
- int g = a << 3; // << 固定補0
- int h = e >> 3; // >> 坐左邊若是1,則補1;若是0,則補0
- int i = a >> 3;
- cout << a << endl;
- cout << b << endl;
- cout << c << endl;
- cout << d << endl;
- cout << e << endl;
- cout << f << endl;
- cout << g << endl;
- cout << h << endl;
- cout << i << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement