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

实在找不到哪里错了啊,哪位大牛帮忙看下 ! 给点测试数据也行 1079

Posted by 19106118 at 2007-05-27 11:49:59
#include <stdio.h>
int main()
{
    double x,y,z,k,d,s,t,dx,a,b;
    long i;
    while(EOF!=scanf("%lf%lf",&x,&y))
    {
        d=x/y;
        if(x/y<=0.5)
        {
            printf("1%c1\n",'/');
            dx=1-d;
        }
        else dx=d;
        s=1;
        while(dx>1e-10)
        {
            z=x/y*s;
            i=(long)z;
            z=(double)i;
            k=z-2;
            t=0;
            while(k<0)k++;
            while(k<=z+2)
            {
                a=k/s-d;
                if(a<0)a=(-1)*a;
                if(a<dx)
                {
                    dx=a;
                    t=k;
                }
                k++;
            }
            if(t!=0)
                printf("%.0f%c%.0f\n",t,'/',s);
            s++;
        }    
        printf("\n");
    }    
}    

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