How to swap without a third variable?

前端 未结 6 1234
死守一世寂寞
死守一世寂寞 2020-12-29 14:12

I have to swap two variables with a number value without using a third variable. What is the simple solution?

6条回答
  •  -上瘾入骨i
    2020-12-29 14:25

    Another popular way is the XOR swapping strategy. http://en.wikipedia.org/wiki/XOR_swap_algorithm

提交回复
热议问题