|  | 
|  | 
| вернуться в форум | Something interesting Послано Sandro  30 июл 2004 00:07My program had WA Test#7. Last two lines were:printf("The distance to the iceberg: %.2lf miles.\n",ans);
 if (ans<99.999) printf("DANGER!");
 But when I changed only the last one:
 if (ans<99.995) printf("DANGER!");
 I got AC!
 
 (Now I think, that I should compare with 100 miles not answer, but it with two digits: so 99.996 is 100.00, but 99.994 is 99.99.)
Yep! We should compare only 2 digits of answer... Yes you are right!I have had same problem.
 It would be better with few clarifications in the problem descriptions...
 
 Edited by author 01.02.2005 17:53
Re: Something interesting Thank you for the hint.I'll never think of that!
 
 Edited by author 18.07.2006 20:12
Re: Something interesting You is good man!ver. #2 =)
 double round( double d ) {//окр. до двух знаков
 d *= 100;
 if( long(d*10)%10>=5 ) ++d;
 return (double(long(d)))/100;
 }
 
 ans = round( ans );
 printf( "The distance to the iceberg: %.2lf miles.\n", ans );
 if( ans < 100/*!!!*/ ) puts( "DANGER!" );
 ver. #3 =)
 ans = floor( ans*100 + 0.5 )/100;
 printf( "The distance to the iceberg: %.2lf miles.\n", ans );
 if( ans < 100 ) puts( "DANGER!" );
 
 Edited by author 14.09.2011 22:30
Re: Something interesting Послано -XraY-  21 мар 2013 19:36I wrote the problem for the second time, but also couldn't understand that.(It needs clarification.
 
 Edited by author 21.03.2013 19:37
 | 
 | 
|