| ||||||||||
| 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 "string.h"
main()
{
int a,b,c,d,x,y,i,temp,z,t;
char s[7],fu;
while(gets(s))
{
a=s[0]-48;
b=s[2]-48;
fu=s[3];
c=s[4]-48;
d=s[6]-48;
if(a==c&&b==d&&fu=='-')
printf("0\n");
else
{
if (fu=='-')
{
c=-c;
}
y=b*d;
x=a*d+b*c;
z=y;
t=x;
while(y!=0)
{
temp=x%y;
x=y;
y=temp;
}
if(a*d+b*c>0)
printf("%d/%d\n",t/x,z/x);
else
printf("%d/%d\n",(-t/x),(-z/x));
}
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator