标签:style blog io ar color os sp on 数据
1/8+3/8 1/4-1/2 1/3-1/3
1/2 -1/4 0
#include<stdio.h> #include<math.h> int main() { int m,a,b,c,d,t1,t2,m1,m2,r; char s; while(scanf("%d/%d%c%d/%d",&a,&b,&s,&c,&d)!=EOF) { m=b*d; m1=b;m2=d; while(b!=0) { r=d%b; d=b; b=r; } a=a*m/d/m1; c=c*m/d/m2; b=d=m/d; if(s=='+') t1=a=a+c; else { t1=a-c;a=sqrt(t1*t1);} t2=b; m=a*b; while(a!=0) { r=b%a; b=a; a=r; } if((t1/b)%(t2/b)==0) printf("%d\n",t1/b); else printf("%d/%d\n",t1/b,t2/b); } return 0; }
标签:style blog io ar color os sp on 数据
原文地址:http://blog.csdn.net/tanggangzuiniu12/article/details/41655955