当前位置:网站首页>Infix expression evaluation
Infix expression evaluation
2022-07-05 08:38:00 【Stay--hungry】
The basic idea :
Define two stacks , Separate for storage Operands And Operator .
- Operands Direct access Operand stack
- For operators op,
- If operator stack is empty , Direct stack
- If it's left bracket
(, Direct stack - If the top of stack operator is left parenthesis
(, And op Is not), Then push directly - if op The priority of the higher than Top of stack operators , Direct stack
- if op The priority of the Below or equal to Top of stack operators , You need to calculate it before entering the stack
- If it's a right parenthesis
), Calculation is required , Until I met(, here(...)The result of the formula in is calculated , take(Kicked out - After each calculation , The situation in the stack will change , want Determine whether the calculation can continue ( That is, whether the current stack top operator still meets the conditions for calculation )
Be careful :(、) Brackets should be considered separately .
Some skills used :
- use
unordered_mapDefines the priority of the operator , The priority of a given operator can be obtained .
unordered_map<char</边栏推荐
- 剑指 Offer 05. 替换空格
- STM32 single chip microcomputer - external interrupt
- leetcode - 445. Add two numbers II
- STM32 summary (HAL Library) - DHT11 temperature sensor (intelligent safety assisted driving system)
- QEMU STM32 vscode debugging environment configuration
- Digital analog 1: linear programming
- Guess riddles (5)
- [nas1] (2021cvpr) attentivenas: improving neural architecture search via attentive sampling (unfinished)
- 轮子1:QCustomPlot初始化模板
- Bluebridge cup internet of things competition basic graphic tutorial - clock selection
猜你喜欢

Bluebridge cup internet of things basic graphic tutorial - GPIO output control LD5 on and off

实例009:暂停一秒输出

Illustration of eight classic pointer written test questions

An enterprise information integration system
![[nas1] (2021cvpr) attentivenas: improving neural architecture search via attentive sampling (unfinished)](/img/3b/c94b8466370f4461875c85b4f66860.png)
[nas1] (2021cvpr) attentivenas: improving neural architecture search via attentive sampling (unfinished)

UE pixel stream, come to a "diet pill"!

STM32 single chip microcomputer - bit band operation

Arduino operation stm32

猜谜语啦(4)
![[three tier architecture]](/img/73/c4c75a453f03830e83cabb0762eb9b.png)
[three tier architecture]
随机推荐
The first week of summer vacation
猜谜语啦(10)
Example 003: a complete square is an integer. It is a complete square after adding 100, and it is a complete square after adding 168. What is the number?
L298N module use
Typical low code apaas manufacturer cases
Example 009: pause output for one second
U8g2 drawing
Business modeling of software model | stakeholders
STM32 single chip microcomputer - external interrupt
Sword finger offer 09 Implementing queues with two stacks
Digital analog 2: integer programming
Lori remote control commissioning record
Daily question - input a date and output the day of the year
Infected Tree(树形dp)
Meizu Bluetooth remote control temperature and humidity access homeassistant
Array integration initialization (C language)
UE pixel stream, come to a "diet pill"!
Speech recognition learning summary
轮子1:QCustomPlot初始化模板
319. 灯泡开关