Created
October 6, 2012 20:11
-
-
Save juanfal/3845963 to your computer and use it in GitHub Desktop.
intercambio correcto con paso de parámetros por referencia
This file contains 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
// nointercambio.cpp | |
// juanfc 2012-06-24 | |
// | |
#include <iostream> | |
using namespace std; | |
void intercambio(int& a, int& b) | |
{ | |
int temp = a; | |
a = b; | |
b = temp; | |
} | |
int main() | |
{ | |
int a, b; | |
cout << "Entrar dos valores a y b: "; | |
cin >> a >> b; | |
cout << "Entrados a y b: " << a << " y " << b << endl; | |
intercambio(a,b); | |
cout << "Después del intercambio: a y b: " | |
<< a << " y " << b << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment