还是直接贴代码
// project1.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include<iostream> #include<stack> #include<sstream> #include<ctype.h> #define LENGTH 1000 using namespace std; int priority(char op){ switch(op){ case '(': return 0; case '+': case '-': return 1; case '*': case '/': return 2; default: return -1; } } //将一个中缀表达式转换成后缀表达式 string inffix_to_suffix(char exp[]){ stack<char> op_stk; string suffix; char *ptr=exp; char operand[LENGTH]; int i=0; while(*ptr!='