木曜日, 11月 06, 2008

Mini.Programming.Practice: On Swap

Problem: Swap two numbers without using a temporary variable.
Code:
int a = 1;
int b = 2;

a = a + b;
b = a - b;
a = a - b;


Output:
a=2;b=1 ^__^

0 comments: