#include <stdio.h>
#include <math.h>
int fun(int m,int n)
{
int r;
if(m<n){r=m;m=n;n=r;}
while(n!=0){r=m%n;m=n;n=r;}
return m;
}
void main()
{
int a1,a2,b1,b2,c1,c2,t,i;
char ch;
printf("分数计算,输入格式形如:1/8+3/8 1/4-1/2\n");
scanf("%d/%d%c%d/%d",&a1,&a2,&ch,&b1,&b2);
t=fun(a2,b2);
c2=a2*b2/t;
if(ch=='-')b1=-b1;
c1=a1*b2/t+b1*a2/t;
for(i=2; i<=abs(c1) && i<=c2;i++)
//最简约
if(c1%i==0 && c2%i==0){ c1/=i; c2/=i;}
if(c1==0 || c2==1)printf("%d\n",c1);
else printf("%d/%d\n",c1,c2);
}