輸入全括號中綴表達式,輸出後綴表達式。如 (a+(b*c)) → abc*+。
+ - * / ^ 入棧) 出棧一個運算符輸出(因全括號,無需比較優先級)( 忽略#include <stack>
#include <cstdio>
#include <iostream>
using namespace std;
int TransformTheExpression() {
int T; scanf("%d\n",&T);
char buf[40200], res[40200];
stack st; int id=0, c;
if ((c=fread(buf,1,40200,stdin))>0) {
for (int i=0;i
無括號版區別
需比較運算符優先級:出棧條件為 棧頂優先級 ≥ 當前優先級。本題有括號故邏輯極簡。