Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int CMMDC(int a, int b){
- if(!b)
- return a;
- return CMMDC(b, a % b);
- }
- int main()
- {
- int x, y, z, w;
- int a, b, c, d, cmmdc;
- cin >> x >> y >> z >> w;
- a = x * w + y * z;
- b = y * w;
- d = b;
- cmmdc = CMMDC(a, b);
- a /= cmmdc;
- b /= cmmdc;
- c = x * z;
- cmmdc = CMMDC(c, d);
- c /= cmmdc;
- d /= cmmdc;
- cout << a << ' ' << b << ' ' << ' ' << c << ' ' << d;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement