c# using bitwise XOR for swapping

前端 未结 7 1527
借酒劲吻你
借酒劲吻你 2020-12-18 12:40
void swap(ref int x, ref int y)
{       x = x ^ y;   y = y ^ x;   x = x ^ y;  }

im learning about bitwise XOR. how is this swapping occurring? it\'

相关标签:
7条回答
  • 2020-12-18 13:23

    swap two number using bitwise operator: use the following PYTHON code:

    m,n=map(int,input().split())
    m=m^n
    n=m^n
    m=m^n
    print(m,n)
    

    i hope it helps.

    0 讨论(0)
提交回复
热议问题