逆波兰表达式
之前没见过遇到了就记录一下,直接看题和解析就能懂,
写出a(b-cd)+e-f/g(h+ij-k)的逆波兰表达式。
根据运算符优先级添加括号。
a(b-cd)+e-f/g(h+ij-k)
= a * (b - (c * d)) + e - (f / g) * (h + (i * j) - k)
= a * (b - (cd)) + e - (fg/) * (h + (ij) - k)
= a * (bcd-) + e - (fg/) * ((hij+) - k)
= (abcd-) + e - (fg/) * (hij+k-)
= (abcd-e+) - (fg/hij+k-)
= (abcd-e+fg/hij+k-*-)
Answered by Miner_Sty