JOIN
 Select a Forum     Round Tables New Member Discussions News Discussions Algorithm Matches Marathon Matches NASA Tournament Lab TopCoder Cookbook High School Matches Sponsor Discussions Development Forums Design Forums Search | Watch Thread  |  My Post History  |  My Watches  |  User Settings View: Flat (newest first)  | Threaded  | Tree Previous Thread  |  Next Thread Forums Tutorial Discussions Dynamic Programming: From novice to advanced need help on this pseudocode
 need help on this pseudocode | Reply I tried to implement this pseudocode for min no of coins but i m not getting right answer for sum=4, 6,7 and when i put sum=10 , the program stop responding.pseudocode-Set Min[i] equal to Infinity for all of iMin[0]=0For i = 1 to SFor j = 0 to N - 1 If (Vj<=i AND Min[i-Vj]+1using namespace std;int main(){ int i,j,sum,coins[]={1,3,5}, min[sum]; cin>>sum; for(i=0;i<=sum;i++) min[i]=99; min[0]=0; for(i=1;i<=sum;i++) { for(j=0;j<3;j++) { if( ( coins[j]<=i) && (min[ i - coins [ j ] ] + 1 < min[i] ) ) { min[i]=min[i-coins[j]] +1; // cout<<<"im out of if condition"; } } cout<
 Re: need help on this pseudocode (response to post by codingnoob88) | Reply //i don't know why did it work at first i think it should be#includeusing namespace std;int main(){// here are the changesint i,j,sum,coins[]={1,3,5};cin>>sum;int min[sum+1];// end of changesfor(i=0;i<=sum;i++)min[i]=99;min[0]=0;for(i=1;i<=sum;i++){for(j=0;j<3;j++){if( ( coins[j]<=i) && (min[ i - coins [ j ] ] + 1 < min[i] ) ){ min[i]=min[i-coins[j]] +1;// cout<<<"im out of if condition";}}cout<
 Forums Tutorial Discussions Dynamic Programming: From novice to advanced need help on this pseudocode Previous Thread  |  Next Thread