JOIN
Get Time
forums   
Search | Watch Thread  |  My Post History  |  My Watches  |  User Settings
View: Flat (oldest first)  | Threaded  | Tree
Previous Thread  |  Next Thread
Re: operators and operands problem (response to post by sharifzadeh) | Reply
It is not Dynamic programming concept
m = length(operands);
n = length(operators);
void Try(i)
{ for (j=0; j++; j<n)
{
x[i]=j;
if (i==m-2)
printf(operands[0],operators[x[0]],...,operators[x[m-2]],operands[m-1]);
else Try(i+1);
x[i]=0;}
}
void main(){
Try(1);
}>
operators and operands problem | Reply
Hi
I am asking my question. I think this problem is related to Dynamic programming concept.

Problem:
We have n operands and m operators. For example:
operands = {a,b,c,d}
operators = {*, -, +, /}

We must put operators between operands and create all of the possibility permutations.
F1 = a+b+c+d
F2 = a+b+c-d
F2 = a+b-c-d
....
Fi = a*b+c/d;

I could not implement the problem.
Is there anyone help me?
RSS