中缀表达式转化成后缀表达式的计算(8)
时间:2025-04-30
时间:2025-04-30
中缀表达式的直接计算,中缀表达式转化成后缀表达式的计算
}
if(ops.size == 0) //若字符栈是空栈,则直接进行入栈的操作
{
}
index++;
continue; Op_push(&ops,op); { } Op_push(&ops,op); break;
}
//判断是否为左括号,直接进行入栈操作 if(chr == '(') { } op.ch = chr; op.level = -1; Op_push(&ops,op); index++; continue;
//判断是否为右括号 if(chr == ')') { char ch1 = Op_getTop(&ops).ch;
} } //进行出栈的操作,知道遇到左括号为止。将出栈的字符加入后续字符中 while(ch1 != '(') { } Op_pop(&ops); index++; continue; char op1 = Op_pop(&ops).ch; tempCh[i++] = op1; tempCh[i++] = '|'; ch1 = Op_getTop(&ops).ch;
//如果字符栈不为空,则一直出栈直到字符栈为空。 while(ops.size != 0) { char op1 = Op_pop(&ops).ch; tempCh[i++] = op1; tempCh[i++] = '|';
下一篇:O型圈技术手册