|
|
back to boardWA6: use this stupid code for correct input Posted by dgorlov 23 Aug 2006 18:49 i have WA6 for correct input of price use procedure like this int read_price(void) { double f; fscanf(inf,"%lf",&f); return (int)((f+1e-9)*100.0); } and you got AC Re: WA6: use this stupid code for correct input Posted by Lion 5 Jan 2007 13:30 Thank you very much!I got AC Re: WA6: use this stupid code for correct input Can you explain me please when expressions (int) (f * 100) and (int)((f+1e-9)*100.0)can differ. (I got AC after using this method, but still can't figure out what the problem is). Thanks in advance :) Edited by author 07.10.2013 03:17 Re: WA6: use this stupid code for correct input I don't understand ! Why when I read data like integer before and after point : int price = before * 100 + after -> is wa6 and when I read data like double: double d; scanf("%lf, &d); int price = (int)(d * 100.0 + 0.1) -> is ok |
|
|