tricky thing

edijs

Programmer
okay, um, can anyone tell me how one can exchange the values of two variables without using a temporary variable? :(
 
not tricky after all...

Code:
Program 1uzd;

Var a,b:integer;

Begin

a:=1;
b:=2;

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


end.

apologees :doh:
 
Why would you want to do that? The C++ STL has swap() which is optimised for your architecture. I guess this one of those "Do it without the obvious way" things.
 
Back
Top