diff --git a/src/swap.c b/src/swap.c index ec09cf2..517cee2 100644 --- a/src/swap.c +++ b/src/swap.c @@ -19,7 +19,10 @@ * @param yp Segundo valor */ void swap(int *xp, int *yp) { - int temp = *xp; - *xp = *yp; - *yp = temp; + if (xp == yp) { + return; + } + *xp = *xp + *yp; + *yp = *xp - *yp; + *xp = *xp - *yp; }