Advertisement
Guest User

Untitled

a guest
May 26th, 2018
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>
  2. #include <cmath>
  3. using namespace std;
  4. int cmmdc (int a, int b)
  5. {
  6.  
  7. while (a!=b){
  8. if (a>b)
  9. a=a-b;
  10. else b=b-a;
  11. }
  12. return a;
  13. }
  14. float x;
  15. int a,b,c,d;
  16. int main()
  17. {
  18. cin >> x;
  19. b = 1;
  20. while (x - floor(x)) {
  21. x = x * 10;
  22. b = b * 10;
  23. }
  24. a = x;
  25. c = cmmdc(a, b);
  26. a = a / c;
  27. b = b / c;
  28. cout << a << " " << b;
  29.  
  30. return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement