Click to See Complete Forum and Search --> : Coin changing Revisited!!


taklim
December 20th, 2008, 05:26 AM
#include<iostream>
#include<cstdlib>

using namespace std;

int main(int argc, char *argv[])
{

int ar[8000], coin[5] = {1,5,10,25,50};

for(int i = 0; i < 7500; i++)
ar[i] = 0; // initialize the array

ar[0] = 1;

for(int j = 0; j < 5; j++)
{
int c = coin[j];
for(int j = c; j < 7500; j++)
ar[j] += ar[j-c];
}

int n;
while(cin >> n)
cout << ar[n] << endl;
system ("pause");
return EXIT_SUCCESS;
}

this coin changing i wanna make coin changing revisited i have no idea what i must change in this algorithm or this is not code that coin changing, im new in this kind programming Plz help me T.T"

cilu
December 20th, 2008, 06:54 AM
"coin changing"? What is that suppose to do? You should first explain the requirements and then what doesn't work.

TheCPUWizard
December 20th, 2008, 11:43 AM
"coin changing"? What is that suppose to do? You should first explain the requirements and then what doesn't work.

This is a NEW thread, on an existing topic by the same poster [who is still refusing to use code tags....]. Many suggestions were given there, which have apparently been ignored.