Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- typedef struct
- {
- int a, b;
- } FRAC;
- int main()
- {
- FRAC f1, f2;
- cin >> f1.a >> f1.b;
- cin >> f2.a >> f2.b;
- int cmmdc, a = f1.a, b = f1.b, r;
- while(b != 0)
- {
- r = a % b;
- a = b;
- b = r;
- }
- cmmdc = a;
- f1.a /= cmmdc;
- f1.b /= cmmdc;
- a = f2.a;
- b = f2.b;
- while(b != 0)
- {
- r = a % b;
- a = b;
- b = r;
- }
- cmmdc = a;
- f2.a /= cmmdc;
- f2.b /= cmmdc;
- if (float(f1.a/f1.b) > float(f2.a/f2.b))
- cout << f1.a << ' ' << f1.b;
- else
- cout << f2.a << ' ' << f2.b;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement