0

Greedy works fine all test pass. Except the values having one value after decimal like 0.1, 4.5. Because in round function I'm using 100 as multiplier, the values become 10, 450 instead of 1 and 45.

bal = roundf(balu * 100);

Any clue how can I use it for both the inputs, for 0.54 as well as 0.3.

1
  • Try simply taking input and storing in a float and then multiply by 100, check if it works.
    – sinister
    Jan 17, 2015 at 16:35

2 Answers 2

1

Are you making an arithmetic error? You state, "in round function I'm using 100 as multiplier, the values become 10, 450 instead of 1 and 45." However, that's exactly what 0.1 and 4.5 should become: 10 and 450, not 1 and 45.

In other words, $0.1 is 10 cents, and $4.5 is 450 cents.

-1

Use round function, not roundf

2
  • No effect, having same problem. Jan 17, 2015 at 17:23
  • You must use round function and bal should be an integer...
    – supeindesu
    Jan 18, 2015 at 15:57

You must log in to answer this question.

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