I did all good in check50 .. except this one thing in greedy
:( input of 4.2 yields output of 18 \ expected output, but not "22\n"
This is my code
CS50 Stack Exchange is a question and answer site for students of Harvard University's CS50. It only takes a minute to sign up.Sign up to join this community
You should use the
round() function to round your
float to the nearest
int! Casting a
float to an
int truncates all the digits after the decimal point. Also, 4.2 isn't necessarily stored as 4.2 because
floats are not precise.