0

How to switch two int with out third int

a=20 b=30 run a=30 b=20

17th Feb 2017, 7:45 AM
Ali Zeawo
Ali Zeawo - avatar
5 Réponses
+ 8
a = a + b; b = a - b; a = a - b;
17th Feb 2017, 7:48 AM
Kawaii
Kawaii - avatar
+ 4
a = (b = b ^ (a = a ^ b)) ^ a;
17th Feb 2017, 5:17 PM
Tamás Barta
Tamás Barta - avatar
+ 2
Sorry, I fixed that. Here is a simpler version: a = a ^ b; b = a ^ b; a = a ^ b;
18th Feb 2017, 7:42 PM
Tamás Barta
Tamás Barta - avatar
0
thanks so much 😍😍😍😍
17th Feb 2017, 7:52 AM
Ali Zeawo
Ali Zeawo - avatar
0
sorry Tamas barta your program is wrong 😶😶😶
18th Feb 2017, 6:23 PM
Ali Zeawo
Ali Zeawo - avatar