谁能帮我解释一下 利用堆栈 求表达式值中的一个函数:
代码如下:
void Process(NumStack *numstack,OpStack *opstack,char x){ double a,b; char c; static double tempnum=0.00000000;static int len=10;static int dot=0,flags=0; if(isdigit(x) || x=='.') { if(x=='.')dot=1; else { if(dot==0) tempnum=tempnum*10+Cint(x); else { tempnum=tempnum+(double)Cint(x)/len; len*=10; } } } else{ if(flags==0 && x!='('){PushNum(numstack,tempnum);tempnum=0.00000000;len=10;dot=0;} switch(Priority(opstack->array[opstack->top-1],x)) { case '>':PushOp(opstack,x);flags=0;break; case '<': PopOp(opstack,&c); PopNum(numstack,&b); PopNum(numstack,&a); PushNum(numstack,Calc(a,b,c));flags=1; Process(numstack,opstack,x);break; case '=':PopOp(opstack,&c);flags=1;break; default:printf("Wrong Express!"); } } }