-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathcode_3.cpp
36 lines (34 loc) · 855 Bytes
/
code_3.cpp
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
35
36
//
// main.cpp
// Algorithm
//
// Created by Mohd Shoaib Rayeen on 31/07/18.
// Copyright © 2018 Shoaib Rayeen. All rights reserved.
//
#include<bits/stdc++.h>
using namespace std;
int count( int *S, int m, int n ) {
int table[n+1];
memset(table, 0, sizeof(table));
table[0] = 1;
for(int i=0; i<m; i++)
for(int j=S[i]; j<=n; j++)
table[j] += table[j-S[i]];
return table[n];
}
int main () {
int number_coin;
cout << "\nNumber of Coins\t:\t";
cin >> number_coin;
int array[number_coin];
cout << "\nEnter Coins\n";
for( int i = 0; i < number_coin; ++i ) {
cin >> array[i];
}
cout << "\nValue for Coin Change\t:\t";
int number;
cin >> number;
cout <<"\nThe result is\t:\t" << count(array , number_coin , number );
cout << endl;
return 0;
}