Created
April 29, 2015 13:09
-
-
Save joffilyfe/65e97dc7407a25423ea7 to your computer and use it in GitHub Desktop.
troca!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
void troca(int *x, int *y); | |
int main(void) { | |
int x, y; | |
x = 10; | |
y = 20; | |
troca(&x, &y); | |
printf("X: %d\n", x); | |
printf("Y: %d\n", y); | |
return 0; | |
} | |
void troca(int *x, int *y) { | |
int aux; | |
aux = *y; | |
*y = *x; | |
*x = aux; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment