0

As per the specifications for greedy, my final line of code just prints an integer followed by \n. printf("%d \n", answer) but I get the same output as check50 rejects greedy even if the correct answer is displayed. What might the problem be?

:( input of 0.41 yields output of 4
\ expected output, but not "0\n"
:( input of 0.01 yields output of 1
\ expected output, but not "0\n"
:( input of 0.15 yields output of 2
\ expected output, but not "0\n"
:( input of 1.6 yields output of 7
 \ expected output, but not "2\n"
:( input of 23 yields output of 92
\ expected output, but not "5\n"
:( input of 4.2 yields output of 18
 \ expected output, but not "4\n"
2

You don't have the correct answers.

  • For 0.41, you are returning 0

    For 0.01, you are returning 0

    For 0.15, you are returning 0

    For 1.6, you are returning 2

    etc.

Your formatting of the answer seems fine, you just aren't returning the correct number of coins.

What happens when you run your program and enter 1.6. You should get 7 coins. Looks like you return 2 instead.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .