C 언어: 비트 연산(bitwise operation)_000025
C언어: xor 연산(swap) /// 연산 x = x ^ y y = y ^ x x = x ^ y /// 예제 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 #include < stdio.h > #include < stdlib.h > #include < time.h > // core gate -------------------------------------------------------------------- extern inline int not_gate( int x) { return (~x); } // not gate extern inline int or_gate( int x, int y) { return (x | y); } // or gate extern inline int and_gate( int x, int y) { return (x & y); } // and gate extern inline int xor_gate( int x, int y) { return (x ^ y); } // xor gate extern inline int l_shift( int x, int bits) { return (x < < bits); } // left shift extern inline int r_shift( int x, int bits) { return (x > > bits); } // right shift //---------------------------------------------------------------------------