Created
July 10, 2020 11:19
-
-
Save bkb181/5accdda54230ed4a854000fca2762063 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int rod_cut(int price[], int n) | |
{ | |
if(n== 0) | |
return 0; | |
int profit = INT_MIN; | |
for(int i = 1; i <= n; i++) | |
{ | |
int cost= price[i-1] + rod_cut(price, n-i); | |
profit=max(cost, profit); | |
} | |
return profit; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment