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"
#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"