Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
不会读入#include <stdio.h> #include <math.h> int a,b,c,d,x,y,i; char fu; int main() { while (scanf("%d/%d%c%d/%d",&a,&b,&fu,&c,&d)!=EOF) { if (fu=='-') c=-c; y=b*d; x=a*d+b*c; i=2; while (i<=(int)fabs((double)x) && i<=y) if (x%i==0 && y%i==0) { x/=i; y/=i; } else i++; if (x==0 || y==1) printf("%d\n",x); else printf("%d/%d\n",x,y); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator