Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

怎么不对呀?帮忙看一下

Posted by sunnyw at 2011-07-18 10:52:46 on Problem 3979
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator