Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int main(){
- float num1f, num2f;//para validar
- int num1,num2,mcd;//para calcular
- do{
- cin>>num1f;
- }
- while(num1f != int(num1f) or num1f<0);
- do{
- cin>>num2f;
- }
- while(num2f != int(num2f) or num2f<0);
- num1 = int(num1f);
- num2 = int(num2f);
- // Calucular m.c.d
- int aux;
- bool bandera = true;
- if (num2>num1){ // Ordenar mayor
- aux = num2;
- num2 = num1;
- num1 = aux;
- }
- // Metodo de Divisiones Sucesivas
- while(bandera){
- if(num1%num2 == 0){
- mcd = num2;
- bandera = false;
- }
- else{
- aux = num1%num2;
- num1 = num2;
- num2 = aux;
- }
- }
- cout<<mcd;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement