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(s[i])==0) {
if(s[i-1]>='0'&&s[i-1]<='9'){
Push(OPND, 10*p + s[i] - '0');
}
else Push(OPND, s[i] - '0');
i++;
}
else
switch(Precede(GetTop(OPTR), s[i])){
case '<':
Push(OPTR, s[i]);
i++;
break;
case '=':
Pop(OPTR, p);
i++;
break;
case '>':
Pop(OPTR, p);
ElemType a, b;
Pop(OPND, b); Pop(OPND, a);
Push(OPND, Operate(a, p, b));
break;
}
}
return GetTop(OPND);
}
有沒有大佬幫忙解釋一下
if(s[i-1]>='0'&&s[i-1]<='9'){
Push(OPND, 10*p + s[i] - '0');
}
else Push(OPND, s[i] - '0');
i++;
}
這段代碼的意思。謝謝!
uj5u.com熱心網友回復:
這只是當中一段代碼吧?轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/72792.html
標籤:C語言
下一篇:寫c++遇到了問題,雖然報錯多,但是同一個型別的錯誤,剛學完c++還不太會改(紅色部分),求大佬們幫我瞅瞅,謝謝
