Question d’entretien chez Halliburton

Brain Teaser: Swap two numbers without using a temporary third variable.

Réponses aux questions d'entretien

Utilisateur anonyme

22 oct. 2013

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

4

Utilisateur anonyme

21 oct. 2012

I provided a solution involving using multiplication/division to store the information about both numbers in a single variable

2

Utilisateur anonyme

6 nov. 2012

Example: A=5, B=7 B=B*A^2=7*25 A=B/(A^2)=7*25/25=7 B=sqrt(B/A)=sqrt(7*25/7)=5

1