#include<cstdio>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include<iostream>
#include<algorithm>
using namespace std;
struct node
{
double num;
char op;
bool flag;
}; //错误点: 建立了一个真的node,以下的类型定义都是node,导致了错误
map<char, int> op; //存放操作数优先级
stack<node> s; //操作符栈
queue<node> q; //后缀表达式序列
string str;
void change() //中缀表达式转后缀表达式
{
int i = 0;
while(i < str.length())
{
node temp, cur;
//区分操作数和操作符
if(str[i] >= '0' && str[i] <= '9') //num 接收到整数,并存入node,压入栈
{
temp.num = str[i++] - '0';
while(str[i] >= '0' && str[i] <= '9' && i < str.length())
{
temp.num = temp.num * 10 + (str[i] - '0');
i++;
简易计算器_中缀表达式转后缀表达式 (STL应用)&&(包含英文括号,有错误请打我)
最新推荐文章于 2022-01-10 17:16:25 发布