Advertisement
paulogp

Troca de entradas

Jul 13th, 2011
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.42 KB | None | 0 0
  1. // Apple Xcode
  2.  
  3.  
  4. #include <stdio.h>
  5.  
  6. // macro
  7. #define troca(the_x, the_y) { int the_temp; the_temp = the_x; (the_x) = (the_y); (the_y) = the_temp; }
  8.  
  9. int main (int argc, const char * argv[])
  10. {
  11.     /* troca de conteudos usando macro */
  12.     int the_x, the_y;
  13.  
  14.     printf("x: ");
  15.     scanf("%i", &the_x);
  16.  
  17.     printf("y: ");
  18.     scanf("%i", &the_y);
  19.  
  20.     troca(the_x, the_y);
  21.  
  22.     printf("x = %i, y = %i", the_x, the_y);
  23.  
  24.     return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement