Coin change Error

Hi would You please tell me whats wrong with this Code ??
For This Problem:- http://online-judge.uva.es/p/v6/674.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include<iostream>
using namespace std ; 
int dir[5]={50,25,10,5,1};
int c[7490];
void counter()
{
	     c[0]=1;
		 for(int k = 1 ; k <7490; k++)
		 {
			 c[k]=0;
		 }
		for(int i=1;i<5;i++)
		{
			for(int j = dir[i]; j<7490 ; j++)
			{
				
				c[j]+=c[j-dir[i]];
			}
		}
	
}
int main()
{  

	int cents ; 
	
	counter();
	while(cin>>cents)
	{
	cout<<c[cents];
		cout<<endl;
	}
	return 0 ; 
}
Last edited on
Firstly, your first for loop in the counter loop is the equivalent of memset(), so use that instead.

Secondly, I don't get the relevence of the number 7490. Can you explain it please. From my understanding of the problem you need to get user input and then find the possible ways for that input.
Topic archived. No new replies allowed.