Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- //problema 3
- unsigned long a,b,c,nr1,nr2,nr3,cmmmc1,cmmmc2,copy_cmmmc1,cmmdc,aux;
- cout<<"nr1=";cin>>nr1;a=nr1;
- cout<<"nr2=";cin>>nr2;b=nr2;
- cout<<"nr3=";cin>>nr3;c=nr3;aux=nr3;
- while (a!=b)
- if (a>b)
- a-=b;
- else
- b-=a;
- while (a!=c)
- if (a>c)
- a-=c;
- else
- c-=a;
- cout<<"cmmdc="<<c<<endl;
- cmmmc1=nr1*nr2/b;copy_cmmmc1=cmmmc1;
- while (copy_cmmmc1!=aux)
- if (copy_cmmmc1>aux)
- copy_cmmmc1-=aux;
- else
- aux-=copy_cmmmc1;
- cmmmc2=cmmmc1*nr3/aux;
- cout<<"cmmmc="<<cmmmc2;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement