/*题目描述
算数四则运算的规则是1)先乘除,后加减;2)从左算到右;3)先括号内,后括号外。 由此,算式4+2*3-10/5的计算顺序为4+2*3-10/5=4+6-10/5=4+6-2=8。 给定
一个以“#”作为结束符的算式,求出算式的结果。
输入
以“#”结尾的表达式,运算数为正整数。每个表达式占一行。
输出
输出表达式运算的结果。
样例输入
4+2*3-10/5#
3*(7-2)#
2*3/2#
样例输出
8
15
3
*/
#include <stdio.h>
#include <iostream>
#include <stack>
#include <cstring>
#include <stdlib.h>
using namespace std;
#define OP_SIZE 7
#define MAX_SIZE 1000
#define TRUE 1
#define FALSE 0
#define ERROR -1
char OP[]={'+','-','*','/','(',')','#'};
char PRIOR[OP_SIZE][OP_SIZE] =
{ // 运算符优先级表
'>','>','<','<','<','>','>',
'>','>','<','<','<','>','>',
'>','>','
算法3-4 表达式求值
最新推荐文章于 2024-10-19 23:56:32 发布