Mar 2, 2017 at 2:08am
if I take this expression -> (1+((2+3)∗(4∗5)))
it converts to this -> +**54+321
Anyone know a solution just based off my function here? I can post my infix to postfix if needed.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
string Expression::inToPre(string myExpression){
// **********MUST BE FULLY PARENTHESIZED**********
myExpression = inToPost(myExpression); //convert infix to postfix, then convert postfix to prefix
int count, length;
length = myExpression.length();
string prefix = "";
for(count = length - 1; count >= 0; count--)
{
prefix += myExpression[count];
}
return prefix;
}
}
|
Last edited on Mar 2, 2017 at 2:09am