Programme of swaping | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 2

Programme of swaping

can anyone help me in a programme of swap

17th Oct 2016, 7:12 AM
Sakshi bissa
1 Antwort
+ 2
The swap function, a classic to show the usefulness of passing variables by reference. void swap(int &a, int &b) { int tmp = a; a = b; b = tmp; } Alternative version, without tmp: void swap2(int &a, int &b) { a = a + b; b = a - b; a = a - b; }
17th Oct 2016, 8:38 AM
Zen
Zen - avatar