Advertisement
Alx09

CMMDC Mono

Feb 12th, 2022
1,109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.45 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int CMMDC(int a, int b){
  6.  if(!b)
  7.     return a;
  8.  return CMMDC(b, a % b);
  9. }
  10.  
  11. int main()
  12. {
  13.   int x, y, z, w;
  14.   int a, b, c, d, cmmdc;
  15.   cin >> x >> y >> z >> w;
  16.   a = x * w + y * z;
  17.   b = y * w;
  18.   d = b;
  19.   cmmdc = CMMDC(a, b);
  20.   a /= cmmdc;
  21.   b /= cmmdc;
  22.   c = x * z;
  23.   cmmdc = CMMDC(c, d);
  24.   c /= cmmdc;
  25.   d /= cmmdc;
  26.   cout << a << ' ' << b << ' ' << ' ' << c << ' ' << d;
  27.     return 0;
  28. }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement