Hi cplusplus forum,
would anyone be able to point me to a link for easy to learn and practising mod and array indexes?
E.g.: I would like to be able to build this algorithm into a C++ code, but need some more practise so it comes automatically.
Algorithm Change(n, D[1..m])
// Implements the greedy algorithm for the change-making problem.
// Input: A nonnegative integer amount n and
// a decreasing array of coin denominations D.
// Output: Array C[1..m] of the number of coins of // each denomination in the change
// or the “no solution” message.
for i <-- 1 to m do
C[i] <-- ⌊n/D[i]⌋
n <-- n mod D[i]
if n = 0 return C
else return “no solution”
Although you might not believe it, I'm actually trying to help you.
I'm trying to help you reconsider the way you post, so that others will be more inclined to offer their help.