Frage im Vorstellungsgespräch bei Colgate-Palmolive

How do you swap two integer variables without creating a temporary variable?

Antworten zu Vorstellungsgespräch

Anonym

23. Sept. 2017

int x = 10; int y = 12; x = x+y //x = 22, y = 12 y = x - y //x = 22, y = 10 x = x-y // x= 12, y=10

1

Anonym

1. Feb. 2019

In python: a, b = b, a