C++: Swap function

Правка en1, от Madiyar, 2015-09-05 02:58:34

Small brainteaser. Do you know that function below doesn't work in some cases.
Try to attack it.

#include <iostream>

using namespace std;

void swap(int &a, int &b){ 
	a = a + b; 
	b = a - b; 
	a = a - b;
}
Теги swap, c++

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский Madiyar 2015-09-05 02:58:34 259 Initial revision (published)