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 |
Re:AC代码在那里找的,给给网站好吗?In Reply To:求助,帮忙找错,一直wa Posted by:zhj5825 at 2006-06-29 15:22:02 > 这道题已经做了很长时间了,而且也看过别人AC的代码,但是仍然找不到自己的错误,而且一直WA。哪位同学能帮忙给看看,非常感谢~ > —————————————————————————————————————————————— > #include<stdio.h> > #include<math.h> > > main() > { > int gain,lose,fenzi,fenmu,gcd,flag=0; > while (scanf("%d %d",&gain, &lose)!=EOF) > { > double result,temp,chazhi=0,min=1; > result=(double)gain/lose; > > for (fenmu=1;fenmu<=lose;fenmu++) > { > fenzi=(int)(fenmu*(result)); > if (fenmu==1) > if ((round(result))>result) > fenzi=(int)round(result); > > while(flag==0) > { > temp=(double)fenzi/fenmu; > chazhi=fabs(temp-result); > if (min>chazhi) > { > min=chazhi; > printf("%d/%d\n",fenzi,fenmu); > break; > } > fenzi++; > if (chazhi>1) > flag=1; > } > flag=0; > } > printf("\n"); > } > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator