需要求解这样的数学方程的代码:56 * 78 +(78/8)? [英] Need a code for soving a Mathematical Equation like this: 56*78+(78/8)?

查看:73
本文介绍了需要求解这样的数学方程的代码:56 * 78 +(78/8)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个可以解决以下等式的代码:-

I need a code which can solve the equations like this :-

56*78+(78/8)


在这种情况下,我们知道必须先解决方括号,然后再除/乘,再加/减.
因此,我需要用于解决此类方程式的代码,该代码在一行中包含多个运算符.

Thnks:)


In this we know that brackets must be solved first and then divide/multiply and then add/subtract.
So, i need a code for solving this kind of equations which contains multiple operators in single line.

Thnks :)

推荐答案

我认为这就是您要寻找的

基于表达式树的C#表达式评估器 [ ^ ]

只需使用上面文章中的示例代码执行以下操作:

I think this is what you are looking for

Expression Evaluator for C# based on Expression Tree[^]

Just do the following using sample code in the above article:

IParser par = new ExpParser();
ExpEvaluator eu = new ExpEvaluator(par); 
string expresion = "56*78+(78/8)"
eu.SetExpression(expresion);
double res =eu.Evaluate();


您应该使用Google搜索数学表达式解析器" .有成千上万的结果.以下是一些有前途的产品:
使用递归下降解析的数学表达式解析器 [ a Tiny Parser Generator v1.2 [简单(x)数值公式分析器 [基于表达式树的C#表达式评估器 [ ^ ]
You should use google to search for "mathematical expression parser". There are thousands of results. Here are some promising ones:
Mathematical Expression Parser Using Recursive Descent Parsing[^]
a Tiny Parser Generator v1.2[^]
Simple(x) Numerical Formula Parser[^]
Expression Evaluator for C# based on Expression Tree[^]


这篇关于需要求解这样的数学方程的代码:56 * 78 +(78/8)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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