Tweet 20 minutes before I got to work, I was tackling against a couple of Mexico City's traffic jams !! and then, I recalled a simple but pretty cool algorithm I used like 5 years ago to swap 2 different variables without using a temporary one. If you're new at programming, there exist a variety of such algorithms, more commonly referred as Sorting Algorithms, and most of them use a temporary variable in order to swap the values they have, so, if u want to optimize your c0de and n1nj4 skillz ;) take a look at this !..
This is the XOR Swap Algorithm, and instead I explain it... A picture is worth a thousand words ;) ...
jueves, 22 de abril de 2010
XOR Swap Algorithm
Publicado por Alejandro Hernández H. en 11:52 a. m.
Etiquetas: xor swap algorithm intercambio swapping variables C programming c0ding coding maths math science