Răspuns:
#include <iostream>
int cmmdc(int a, int b)
{
int r=a%b;
while (r)
{
a=b; b=r;
r=a%b;
}
return b;
}
int cmmmc(int a,int b)
{
int c=cmmdc(a,b);
return (a*b)/c;
}
using namespace std;
int main()
{
int a,b,d,m;
cin >> a >> b;
d=cmmdc(a,b);
m=cmmmc(a,b);
cout << d << " " << m;
return 0;
}
Explicație:
se poate afla ambele in acelasi subprogram subprogram... dar dace se cer doua...