|
|
вернуться в форумIf you like using printf,pay attention to this! I thought my algo is all right but got wa3&5. Why? Because I saw this in the statement: rounded to the integer So,I wrote printf("%.0lf",a+0.49999999); But it seemed to be wrong. I checked again and again,finally I found the problem: When you use %x.ylf,where x and y are numbers,the result is automatically rounded. However,when using (int)a,it means FLOOR. So,if you want to write rounded ans,there are 2 ways: printf("%d",(int)(a+0.499999999)); or printf("%.0lf",a); Re: If you like using printf,pay attention to this! Послано Vlad 1 дек 2012 04:52 Nice! Now it works, thank you :0 |
|
|