I am trying to run the recursive program for the rod cutting problem. My code compiles but fails to build. I am using MS Visual Studio 2010, here's the code:
Code:
#include<stdio.h>
#include<stdlib.h>
#define MAX(a,b) ((a)> (b) ? (a) :(b))
int max_revenue (int *price, int length)
{
int q , i;
if (length == 0)
return 0;
q = -1;
for (i = 1; i <=length; i++)
{
q = MAX(q, (price[i-1] + max_revenue(price, length-i)));
}
return q;
}
int main()
{
int *price;
int max_price;
price = (int *)malloc(4*sizeof(int));
price[0] = 1;
price[1] = 5;
price[2] = 8;
price[3] = 9;
max_price = max_revenue (price, 4);
return 0;
}
I get an error- unresolved externals. Please help!