Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int cmmdc (int a, int b)
- {
- while (a!=b){
- if (a>b)
- a=a-b;
- else b=b-a;
- }
- return a;
- }
- float x;
- int a,b,c,d;
- int main()
- {
- cin >> x;
- b = 1;
- while (x - floor(x)) {
- x = x * 10;
- b = b * 10;
- }
- a = x;
- c = cmmdc(a, b);
- a = a / c;
- b = b / c;
- cout << a << " " << b;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement