Jump to content

[C++]C.M.M.M.C. si C.M.M.D.C.


FnZ
 Share

Recommended Posts

/*Cel mai mare divizor comun si Cel mai mic multiplu comun*/
#include <iostream>

using namespace std;

int main()
{
    int a,b,cmmmc,cmmdc,ca,cb;
    cout<< "Alege primul numar"<< " ";
    cin>>a;
    cout<< "Alege al doilea numar"<< " ";
    cin>>b;
    ca=a;
    cb=b;
    while(a!=b)
    {
        if(a>b)
        {
            a=a-b;
        }
        else
        {
            b=b-a;
        }
    }
    cmmdc=a;
    cmmmc=ca*cb/cmmdc;
    cout<< "C.M.M.D.C.="<<cmmdc<<endl;
    cout<< "C.M.M.M.C.="<<cmmmc<<endl;
    return 0;
}

Mult succes

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.