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:这题的数据不严啊!In Reply To:这题的数据不严啊! Posted by:JeRJupiter at 2009-09-05 00:02:30 > 遇到1.45的时候.输出结果为6 card(s)和5 card(s)的代码都能pass! > 数据不够严啊.估计没有出到这样的数据! 如下的代码: #include <stdio.h> int main() { float a; int n; float result=0; while(true) { scanf("%f",&a); if(a==0.0) break; for (n=2,result=0; result<=a; n++) //这句这样是对的,测1.45的时候输出5 //for (n=2,result=0; result<a; n++) //这句居然可以pass!输出是6! { result += (float)1 / n; } printf("%d card(s)\n",n-2); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator