Created
November 4, 2016 11:26
-
-
Save brayancruces/845a2ce0b9e834c850bfbdd3bd2d1371 to your computer and use it in GitHub Desktop.
Ejercicio 2
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
/* | |
04/11/2016 | |
Ejercicio 1 | |
Hoja de ejercicios | |
To-do: | |
Recursividad [Completa] | |
Lambda [Incompleto] | |
*/ | |
#include <iostream> | |
#include <vector> | |
using namespace std; | |
class Euclides | |
{ | |
private: | |
int a, b; | |
public: | |
// componentes | |
Euclides() {}; | |
~Euclides() {}; | |
void asignarNumeros(int a, int b); | |
int MCD(int a, int b); | |
int calcularMCD(); | |
void generarNumeros(); | |
}; | |
int Euclides::MCD(int x, int y) { | |
int n1 = x; | |
int n2 = y; | |
if (n2 == 0) | |
return n1; | |
else | |
return MCD(n2, n1%n2); | |
} | |
int Euclides::calcularMCD() { | |
return MCD(this->a,this->b); | |
} | |
void Euclides::asignarNumeros(int x, int y) { | |
this->a = x; | |
this->b = y; | |
} | |
int main(){ | |
//vector<Euclides> vec; | |
Euclides objEuclides; | |
objEuclides.asignarNumeros(4,16); | |
cout<< "El MCD es :" << objEuclides.calcularMCD(); | |
cout << endl; | |
system("PAUSE"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment