Advertisement
nicuvlad76

Untitled

Dec 16th, 2020
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct fractie
  5. {
  6. int x,y;
  7. };
  8. fractie f1,f2, fmax;
  9.  
  10. fractie Cmmdc(fractie f) ///functie ce returneaza o variabila de tip struct
  11. {
  12. fractie tmp=f;
  13. int a=tmp.x, b=tmp.y,r;
  14. while(b!=0){r=a%b; a=b;b=r;}
  15. tmp.x/=a;
  16. tmp.y/=a;
  17. return tmp;
  18. }
  19.  
  20. int main()
  21. {
  22. cin>>f1.x>>f1.y;
  23. cin>>f2.x>>f2.y;
  24.  
  25. if(f1.x*f2.y>f2.x*f1.y) fmax=f1;///atribuirea = copiere bit cu bit
  26. else fmax=f2;
  27. fmax=Cmmdc(fmax);
  28. cout<<fmax.x<<" "<<fmax.y;
  29. return 0;
  30. }
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement