表达式计算 [英] EXPRESSION CALCULATION

查看:62
本文介绍了表达式计算的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何计算c#中的表达式

HOW TO CALCULATE EXPRESSION IN c#

如51 + 25/28 + 1-(85 * 87)+ 54 + 36 * 98-45

LIKE 51+25/28+1-(85*87)+54+36*98-45

推荐答案

家庭作业问题?

Homework questions?

基于表达式的计算器是中学学习"字符串标记化"的流行作业。和"堆叠操纵"/"树横向"和"树横向操作"。技术。

Expression based calculator is a popular homework for secondary school to practice "string tokenizing" and "stack manipulation"/"tree transversal" technique.

编辑:添加"树横向"因为我已经看到了基于这两种方法的解决方案。

added "tree transversal" because I've seen solutions based on both approach.

提示:在标记字符串的过程中,如果你跟踪运算符优先级和在优先级变化上添加缺少的括号,可以大大简化计算器逻辑。

Tips: On the process of tokenizing the string, if you keep track of the operator precedence level and add missing parenthesis on precedence level change, the calculator logic can be significantly simplified.


这篇关于表达式计算的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆