ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Common Board

round, c++
Posted by Ilya_Malinovsky 7 Aug 2010 18:45
Excuse me, I have next problem: I have got 'compilation error' twice because of using function round() from library 'cmath'. But it works normally in Code::Blocks on my PC. What is the problem and how can I substitute round function?
Re: round, c++
Posted by Andrew Hoffmann aka SKYDOS [Vladimir SU] 7 Aug 2010 19:29
а что именно в сообщении об ошибке выдаёт компилятор?
Re: round, c++
Posted by Ilya_Malinovsky 7 Aug 2010 19:54
941ef0f3-e7a3-4f31-a9b3-5be1b580cf1b
941ef0f3-e7a3-4f31-a9b3-5be1b580cf1b(48) : error C3861: 'round': identifier not found
Re: round, c++
Posted by Artem Khizha [DNU] 7 Aug 2010 20:56
> how can I substitute round function?
I'm not sure about all these tricks, but this may work:
> double d;
> int x = (int)(d+0.5);

For me round worked just fine, but last time I had used it before compiler was changed. Btw, what compiler do you use in code::blocks? GCC?
Re: round, c++
Posted by Vladimir Yakovlev (USU) 7 Aug 2010 21:04
Use floor or ceil