Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2020
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. int h,h1,x,y,r;
  5. struct fractie
  6. {
  7. int numa,numi;
  8. }a,b;
  9. int main()
  10. {int x,y;
  11. cin>>a.numa>>a.numi>>b.numa>>b.numi;
  12. if(a.numa*b.numi>a.numi*b.numa)
  13. {
  14. x=a.numa,y=a.numi;
  15. while(y)
  16. {
  17. r=x%y,x=y,y=r;
  18. }
  19. cout<<a.numa/x<<" "<<a.numi/x;
  20. }
  21. else
  22. {x=b.numa,y=b.numi;
  23. while(y)
  24. {
  25. r=x%y,x=y,y=r;
  26. }
  27. cout<<b.numa/x<<" "<<b.numi/x;
  28. }
  29.  
  30. return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement