![]() |
Hello all,
I need to do a program for school but I'm completely lost :( I cannot think of a algorithm... the question is how many combinations there are if I have unlimited supply of 50 pence, 1 J and 2 J coins, how many different ways is it possible to make a sum of X amount? Thanks all |
Hava a variable, we'll call counter, and initialize at 0. have a few nested loops which calculate every possible combination of coins and every time X amount is reached, increment counter.
|
I don't understand the problem :huh:
|
Actually I do not really understand the currency you are using, could you explain what !j and 2J is in relation to 50pence? Or use good old canadian/american currency systems :P
|
The good ol' dollar :)
|
Actually J = Pound Sterling :P
PS During my Physics lesson today, I tought of the algorithm for 5 minutes and wrote this source code: :
#include <iostream>Can someone test it and review to see if it's alright, because I don't have a compiler at school... Thanks very much |
Looks perfect. Nice to see you do more work in Physics than I do... even if it's irrelevant :P
|
| All times are GMT -5. The time now is 8:07 PM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC