-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
27 lines (24 loc) · 672 Bytes
/
main.cpp
File metadata and controls
27 lines (24 loc) · 672 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <iostream>
using namespace std;
void machaca1(int x, int* y){
*y = x;
return;
}
void machaca2(int x, int& y){
y = x;
return;
}
int main(int argc, char** argv){
int a, b;
cout << "Escribe dos datos enteros: " << endl;
cin >> a >> b;
int copia = b;
cout << "Antes de machaca1: " << a << " y " << b << endl;
machaca1(a, &b);
cout << "Después de machaca1: " << a << " y " << b << endl << endl;
b = copia; // restauramos b para probar el segundo método
cout << "Antes de machaca2: " << a << " y " << b << endl;
machaca2(a, b);
cout << "Después de machaca2: " << a << " y " << b << endl;
return 0;
}