+ 6

¿Como funciona el swap en c++?

funcionamiento de método swap

4th Jul 2018, 6:22 PM
Heriberto Domínguez
Heriberto Domínguez - avatar
2 Réponses
+ 5
// using temp variable void swap (int *x , int *y) { temp= *x; *x = *y; *y = temp; } // without using extra temp. variable void swap (int *x , int *y) { *x = (*x) ^ (*y); *y = (*x) ^ (*y); *x = (*x) ^ (*y); } void swap (int *x , int *y) { *x = (*x) + (*y); *y = (*x) - (*y); *x = (*x) - (*y); } void swap (int *x , int *y) { *x = (*x) * (*y); *y = (*x) / (*y); *x = (*x) / (*y); } void swap (int *x , int *y) { *x = (*x + *y) - (*y= *x); }
4th Jul 2018, 6:39 PM
Nikhil Dhama
Nikhil Dhama - avatar
+ 7
thank you so much
4th Jul 2018, 6:48 PM
Heriberto Domínguez
Heriberto Domínguez - avatar