Sort 1051 Discussions, By:
Please Login in order to post a comment
When the Domain is C++, why are we talking about scanf and printf. These are so C!!
This challenge is well resentative of why I usually dislike website claiming to teach you C++.
It encourage using C. I love C, but C != C++, don't say it's C++ if you ask to use C. Some guys told me it's because it easier to teach that way because you don't have to talk about the C++ syntax too fast. So you have to teach C syntax instead and then you have to forget what you learn and learn another syntax instead. Yeah, easier for sure... Want to learn C ? Go learn it. Want to learn C++ ? Go learn it too, directly, you don't need to learn C first !
It show false arbitrary statement like "cout is slower". It may be, but it's not true every time, cout is subjet to a lot of improvement when you know it and use it the way it should be.
It teach bad pratices: you should not include header you don't need. And you don't need to use printf/scanf, so you don't need cstdio. Neither you need other headers like math or whatever I saw in other challenges. And you SHOULD NOT make a global "using namespace std;". It's a really bad practice, you should do that in scope only. Even better : don't do using namespace at all. It's only few letters, it's not like if the namespace was "system::standard::iostream::console" or something.
Challenge requirements are not all specified : it require some specific precision on float and double but nothing is told about it. Nothing is told about what to do if the user input is not what you were waiting, etc... leading to learning bad pratice again.
So please modify the callenge to correct thoses point, lot of people are complaining about it. Please remember that people are supposed to learn from theses samples. Don't let them learning bad practices.
It would be helpful if this were updated to account for the fact that all the test cases require 3 decimal precision for the float (%.3f) and 9 decimal precision for the double (%.9lf).
I think this challenge might be better suited in the C domain. I don't understand why the syntax they are teaching wouldn't use c++ 11 features for I/O.
For some reason beyond my understanding, the test cases will not pass if you don't set the precision for float to 3 and double to 9.
You can do this by including and using setprecision() while printing like this:
cout << setprecision( 3 ) << fixed << floatVar << endl;
cout << setprecision( 9 ) << fixed << doubleVar << endl;