My train of thought: first converted into a postfix expression, again according to the postfix expression method,
C + + 11
Open the O2
Submit code:
A big pile head//import file
# include
# include
# include
# include
# include
# include
# include
# include
# include
# include
# include
# include
# include
# include
using namespace std;
Int main ()
{string in x;//in is the input string, a string of x is used for computing, stack
//then add ', because I use the '. 'segmentation number, behind can according to the'. 'to fill Numbers stack with ten digits, the digits, otherwise, I don't know what are the two number or a number, is wrong, the code behind (naturally) x +='. '. }} else {the if (in [I]=='+' | | in [I]=='-') {//if (! Op. Empty ()) {//if the stack won't have time to back calculation, the if (op. The top ()=='*' | | op. The top ()=='/') {//because of the priority, the multiplication sign must be pressure on the add and subtract Numbers, add and subtract Numbers cannot be pressed on the multiplication sign devide, while (! Op. Empty ()) {//all calculation, empty station, x +=op. Top ();//directly into x, op. Pop ();//useless, throw trash can, x +='. './/I'm still in 'to separate,}//after all this, will to push at the back,}} op. Push in [I]);//push this symbol,} else {op. Push in [I]);//, highest priority, don't have to and add and subtract Numbers that determine priorities,}}} while (! Op. Empty ()) {//to empty stack, x +=op. Top (); Op. Pop (); X +='; }
//cout
CodePudding user response:
Used c + + 11