This equation swaps two numbers without a temporary variable, but uses arithmetic operations:
a = (a+b) - (b=a);
How can I do it without arithmetic operations? I was thinking about XOR.
a=a+b; b=a-b; a=a-b;
This is simple yet effective....
1.4m articles
1.4m replys
5 comments
57.0k users