Guest User

Untitled

a guest
Oct 17th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. #include<iostream.h>
  2. #include<stdio.h>
  3. #include<math.h>
  4. using namespace std;
  5. double GCD(double x, double y)
  6. {
  7. double value;
  8. value=fmod(x,y);
  9. if(value==0)
  10. return y;
  11. else
  12. GCD(x, value);
  13. }
  14.  
  15. int main()
  16. {
  17. double num, den;
  18. cin>>num>>den;
  19. double numcopy=num,dencopy=den;
  20. num/=GCD(num,den);
  21. den/=GCD(numcopy,dencopy);
  22. cout<<"\n"<<num<<"\t"<<den;
  23. cout<<"\n";
  24. return 0;
  25. }
Add Comment
Please, Sign In to add comment