👤

Doua numere intregi a si b. Doua metode de calcul a c.m.m.d.c . Trebuie sa fac acelasi lucru si pentru c.m.m.m.c. :\

Răspuns :

int cmmdc(int a, int b)
{int r;

while (r!=0)
{a=b;
b=r;
r=a%b;
}
return b;
}
int main()
{int a,b;
cin>>a>>b;
cout<<"C.m.m.d.c: "<<cmmdc(a,b)<<endl;
cout<<"C.m.m.m.m.c: "<<a*b/cmmdc(a,b);
}
Am facut in subprogram.