Échanger 2 variables sans utiliser de tampon
Par M. Pomme le dimanche, avril 9 2006, 11:25 - d10[gression] - Lien permanent
int x = 4; int y = 7;
x += y; y = x - y; x -= y;
"Génial", non ?
Enfin bon.
Par M. Pomme le dimanche, avril 9 2006, 11:25 - d10[gression] - Lien permanent
int x = 4; int y = 7;
x += y; y = x - y; x -= y;
"Génial", non ?
Enfin bon.
Commentaires
bof...
Ben.. c'est bien si on est limité en espace mémoire.
euh...
Encore mieux :
a,b=b,a
(c'est du python, et ça marche... ;-) )