Timeline for cs50 Problem Set 1: Greedy. float 0.01 problem
Current License: CC BY-SA 3.0
7 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jul 4, 2016 at 7:27 | vote | accept | Domas Kalinauskas | ||
Jul 4, 2016 at 7:27 | comment | added | Domas Kalinauskas | I've taken another look at your comment and the tip giving greedy walkthrough and figured out the problem. I was not rounding it properly. All I needed to do when converting to an int is to also include the round in the same command. | |
Jul 3, 2016 at 20:38 | comment | added | Domas Kalinauskas | It prints out 419 which means that as the idea giving walkthrough thing said I need to somehow round it? I've tried doing roundf and round but I can't seem to make it work :/ | |
Jul 3, 2016 at 7:28 | comment | added | Cliff B |
When you add all those coins together, what's the total? Try printing out change immediately after int change = changefloat * 100;
|
|
Jul 3, 2016 at 7:21 | comment | added | Domas Kalinauskas | This fixes all my problems!... almost. the only single problem left is that it doesn't pass the check for 4.2. It says it uses 22 instead of 18 and I have no idea what's wrong. I did add some parts to the code so it tells me how much it uses of a specific coin and instead of using 16 of 25 and 2 of 10 it uses 16 of 25, 1 of 10, 1 of 5 and 4 of 1. Any hints at how to fix this? edit: updated code in the top post thingy | |
Jul 3, 2016 at 5:27 | vote | accept | Domas Kalinauskas | ||
Jul 3, 2016 at 5:41 | |||||
Jul 2, 2016 at 21:32 | history | answered | Cliff B | CC BY-SA 3.0 |