-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathejemplos.cpp
63 lines (50 loc) · 970 Bytes
/
ejemplos.cpp
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
*
* $ g++ ejemplos.cpp -o salida
* $ ./salida
*
*/
// 3.
#include<iostream>
using namespace std;
int mcd(int a, int b);
int mcd(int a, int b){
while(b){
int aux = b;
b = a%b;
a = aux;
}
return a;
}
int main(int argc, char *argv[]){
if(argc < 0){
cout<<"Debe haber al menos dos numeros"<<endl;
cout<<"Ej. -> ./salida 3 4"<<endl;
}else{
int a = atoi(argv[1]);
int b = atoi(argv[2]);
cout<<"El MCD de a = "<<a<<", b = "<<b<<endl;
cout<<" es: "<<mcd(a,b)<<endl;
}
return 0;
}
// 2.
#include<iostream>
using namespace std;
int main(int argc, char *argv[]){
cout<<"No. argumento(s): "<<argc<<endl;
cout<<"Nombre del programa: "<<argv[0]<<endl;
for(int i=1; i < argc ;i++){
cout<<"Dato: "<<argv[i]<<endl;
}
return 0;
}
// 1.
#include<iostream>
using namespace std;
typedef int Entero;
int main(){
Entero entero = 33;
cout<<"El doble de "<<entero<<" es: "<<(entero*2)<<endl;
return 0;
}