高分求解Java问提,用堆栈实现中缀表达式转后缀表达式?

来源:百度知道 编辑:UC知道 时间:2024/06/25 06:16:04
要源程序~~
你好,我想知道,假如堆栈中是+(,这时碰到了-,这时要怎没比较呢,你只要告诉我思路就可以哦

public class s {

public static void main(String[] args) {
midfix();

}
static boolean push(char c)
{
if(stackLength<50)
{
myStack[stackLength++]=c;
return !STACK_FULL;
}
else
return STACK_FULL;
}

static char pop()
{
if(!isEmpty())
{
return myStack[--stackLength];

}

else
return STACK_EMPTY;
}
static boolean isFull()
{
if (stackLength==50)
return true;
else
return false;
}
static boolean isEmpty()
{
if (stackLength==0)
return true;
else
return false;
}
static int length()
{
return stackLength;
}
static char topValue()
{
if(!isEmpty())
return myStack[stackLength-1];
else
return STACK_EMPTY;
}