Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- struct fractie
- {
- int x,y;
- };
- fractie f1,f2, fmax;
- fractie Cmmdc(fractie f) ///functie ce returneaza o variabila de tip struct
- {
- fractie tmp=f;
- int a=tmp.x, b=tmp.y,r;
- while(b!=0){r=a%b; a=b;b=r;}
- tmp.x/=a;
- tmp.y/=a;
- return tmp;
- }
- int main()
- {
- cin>>f1.x>>f1.y;
- cin>>f2.x>>f2.y;
- if(f1.x*f2.y>f2.x*f1.y) fmax=f1;///atribuirea = copiere bit cu bit
- else fmax=f2;
- fmax=Cmmdc(fmax);
- cout<<fmax.x<<" "<<fmax.y;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement