Advertisement
STANAANDREY

ex3

Jan 20th, 2019
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6. //problema 3
  7. unsigned long a,b,c,nr1,nr2,nr3,cmmmc1,cmmmc2,copy_cmmmc1,cmmdc,aux;
  8.  cout<<"nr1=";cin>>nr1;a=nr1;
  9.  cout<<"nr2=";cin>>nr2;b=nr2;
  10.  cout<<"nr3=";cin>>nr3;c=nr3;aux=nr3;
  11. while (a!=b)
  12.     if (a>b)
  13.     a-=b;
  14.     else
  15.     b-=a;
  16.     while (a!=c)
  17.         if (a>c)
  18.         a-=c;
  19.     else
  20.         c-=a;
  21.     cout<<"cmmdc="<<c<<endl;
  22.    cmmmc1=nr1*nr2/b;copy_cmmmc1=cmmmc1;
  23.    while (copy_cmmmc1!=aux)
  24.     if (copy_cmmmc1>aux)
  25.         copy_cmmmc1-=aux;
  26.       else
  27.         aux-=copy_cmmmc1;
  28.    cmmmc2=cmmmc1*nr3/aux;
  29.    cout<<"cmmmc="<<cmmmc2;
  30.  
  31.  return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement