Home > Back-end >  Expression evaluation data structure
Expression evaluation data structure

Time:09-25

ElemType EvaluateExpression () {
SqStack OPTR OPND;
InitStack (OPTR);
Push (OPTR, '#');
InitStack (OPND);

Char p, s [100];
Gets (s);
int i=0;
While (s [I]!='#' | | GetTop (OPTR)!='#') {
If (In [I] (s)==0) {
If (s] [I - 1 & gt;='0' & amp; & S [I - 1] <='9') {
Push (OPND, 10 * p + s [I] - '0');
}
The else Push (OPND, s [I] - '0');
i++;
}
The else
The switch (Precede (GetTop (OPTR), s [I])) {
Case '& lt; ':
Push (OPTR, s [I]);
i++;
break;
Case: '='
Pop (OPTR, p);
i++;
break;
Case '& gt; ':
Pop (OPTR, p);
ElemType a, b;
Pop (OPND, b); Pop (OPND, a);
Push (OPND to Operate (a, p, b));
break;
}
}
Return GetTop (OPND);
}


Is there a big help to explain the
If (s] [I - 1 & gt;='0' & amp; & S [I - 1] <='9') {
Push (OPND, 10 * p + s [I] - '0');
}
The else Push (OPND, s [I] - '0');
i++;
}
The meaning of this code, thank you!

CodePudding user response:

This is just a piece of code?
  • Related