Hi All
I'm a student studying C++ programming. I've got an assignment
question where I don't even have an idea how to attack the
problem. The program is to input a value (like $1. $2. $5..)
and spit out a table showing all the different cominations of coins
that could be used to make up that value. So for $0.10 the table
would look like:
10 = 10
10 = 5 + 5
10 = 5 + 1 + 1 + 1 + 1 + 1
10 = 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1
At first I tried to do a series of for loops,
for ( five times )
for ( coin < money )
for ( coin < money )
for ( coin < money )
{ for ( coin < money )
{ cout << "+ 25 "; }
cout << " + 10";
}
cout << " + 5";
}
cout << "+ 1";
}
}
But this just gave me a table of;
10 + 10 + 10...
5 + 5 + 5..
1 + 1 + 1 + 1...
I've looked at Permutations and combinations math wise but this
method just gives me the number of permutations, not what they are.
I'm not asking for code, just an idea of how to attack the question.
Thanks for any ideas.
... - InterNet E-Mail: awalker@spruce.nic.bc.ca -or- alex.walker@cgate.com
---
---------------
* Origin: Community Access Courtenay, BC (604) 338-4597 (1:3412/1)
|