Browse Source

optimize swap

tags/1.0.0
Chris Cromer 11 months ago
parent
commit
6ff4147448
Signed by: Chris Cromer <chris@cromer.cl> GPG Key ID: 39CC813FF3C8708A
1 changed files with 6 additions and 3 deletions
  1. 6
    3
      src/swap.c

+ 6
- 3
src/swap.c View File

@@ -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;
}

Loading…
Cancel
Save