Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Avem fractiile a/b si c/d.
- Afisati fractia diferenta (x/y = a/b-c/d) sub forma ireductibila
- Ex: 17/75 - 2/75 = 1/5
- Date de intrare a,b,c,d
- Date de iesire: x,y
- */
- #include <iostream>
- using namespace std;
- int main(){
- int a,b,c,d;
- int x,y;
- cin >> a >>b>>c>>d;
- x=a*d-c*b;
- y=b*d;
- int A=x,B=y,r;
- while(B!=0){
- r=A%B;
- A=B;
- B=r;
- }
- cout << x/A << " " << y/A;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement