victorialais

nao ha modificação ponteiros

Sep 13th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.37 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4.  
  5. void incrementa (int *valor) {
  6.    
  7.     (*valor)++;
  8. }
  9.  
  10.  
  11. void swap (int x, int y) {
  12.    
  13.    
  14.     int aux = x;
  15.     x = y;
  16.     y = aux;
  17.    
  18. }
  19. int main (){
  20.  
  21. int x = 10;
  22. int y = 5;
  23.  
  24. cout << "X: " << x << endl;
  25. cout << "Y: " << y << endl;
  26. swap(x, y);  
  27. cout << "X: " << x << endl;
  28. cout << "Y: " << y << endl;
  29.  
  30.  
  31. return 0;
  32.  
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment