//idea: given two fractions.
Add them and display result
//Dennis
#include
<iostream>
using
namespace std;
int
gcd(int a,int
b)
{
if (a<b) return
gcd(b,a);
if (b==0) return
a;
else return
gcd(b,a%b);
}
int
main()
{
int a,b,c,d,g;
//vars, gcd
char o,t;
//operator, temp
while(cin>>a>>t>>b>>o>>c>>t>>d && (a|b|c|d)!=0)
{
int top=a*d+b*c;
int bottom=b*d;
int whole=0;
g=gcd(top,bottom);
top/=g;
bottom/=g;
if (top>=bottom)
{
whole=top/bottom;
top%=bottom;
}
if (whole>0)
{
cout<<whole;
if (bottom>1) cout<<"
and ";
}
if (bottom>1) cout<<top<<"
/ "<<bottom;
cout<<endl;
}
cout<<"Zhzyatslya,
I did this for YOU!"<<endl;
return 0;
}
/*
1 / 3 + 4
/ 3
1 / 1 + 2
/ 3
1 / 3 + 1
/ 3
0 / 0 + 0
/ 0
*/