using System.Text.RegularExpressions; using System; class stack { private string[] buffer; private int top; private int maxsize; public stack(int size) {// ?????? top=0; maxsize=size; buffer=new string[maxsize]; }//????? ?????? private bool isEmpty() {//???? ???? ???? if(top<=0) return true; return false; }//end of isEmpty private bool isFull() { if(top>=maxsize) return true; return false; }//end of isFull public string pop() { if(!isEmpty()) return buffer[--top]; return null; }//end of pop public void push(string elm) { if(!isFull())buffer[top++]=elm; }//end of push public string topElm() { if(!isEmpty()) return buffer[top-1]; return null; } }// end of class stack class infixToPostfix { string [] exp; string operators; int expLen,tokenIndex; stack st; public infixToPostfix(string [] expEval,int len) { exp=expEval; expLen=len; tokenIndex=0; operators="^*/+-"; st=new stack(len); }//end of infixToPostfix private string getToken() { string temp; if(this.tokenIndex>=expLen) return null; temp=exp[this.tokenIndex++]; return temp; }//end of get Token private bool isOperator(string op) { if(op.Length==0) return false; else if((op.Length>1)||char.IsDigit(op,op.Length-1)||(operators.IndexOf(op)==-1)) return false; return true; }//end of isOperator public int getOpLen() { return expLen; }//end of getOpLen public string [] inToPost() { string temp1; string temp2; string [] operands=new string[expLen]; int operandIndex=0; while((temp1=getToken())!=null) { if(temp1.Equals("(")) st.push(temp1); else if(temp1.Equals(")")) { while(st.topElm()!=null && !st.topElm().Equals("(")) { temp2=st.pop(); operands[operandIndex++]=temp2; } st.pop(); } else if(isOperator(temp1)) { if((temp2=st.topElm())!=null) { if(temp2.Equals("(")) st.push(temp1); else if(operators.IndexOf(temp1)