This is a code to solve the coin change problem. I would like to share it.
#include <iostream>
#include <cstring>
using namespace std;
int n, i, j;
int dp[7500];
int coins[5] = { 1, 5, 10, 25, 50 };
int main()
{
// removed unnecessary recursion and array in here.
memset(dp, 0, sizeof(dp));
dp[0] = 1;
for (int i = 0; i < 5; i++) {
for (int j = coins[i]; j < 7500; j++) {
dp[j] += dp[j - coins[i]];
}
}
while (cin >> n)
{
cout << dp[n] << endl;
}
return 0;
}