Two numbers a,b.
XOR based solution:
a = a^b
// now a contains the 'a xor b'
b = b^a
// now b contains 'a'
a = a^b
// now a contains 'b'
XOR based solution:
a = a^b
// now a contains the 'a xor b'
b = b^a
// now b contains 'a'
a = a^b
// now a contains 'b'
ok thanks for this post it's quite informative and I have learned new things.
ReplyDeletemehndi design