简体   繁体   English

计算数组中的数学方程

[英]Evaluating a mathematical equation in an Array

Im working on a simple app about factoring polynomials and so far i have used我正在开发一个关于分解多项式的简单应用程序,到目前为止我已经使用过

.equals();

to check and compare the answers.检查和比较答案。 But i realized that for example 4x^2 + 2x - 4 is the same as 2x + 4x^2 - 4. I am wondering how i can check without adding "2x + 4x^2 - 4" in my array?但我意识到例如 4x^2 + 2x - 4 与 2x + 4x^2 - 4 相同。我想知道如何在不添加“2x + 4x^2 - 4”的情况下进行检查? I thought about splitting it into tokens but how do i compare it tho?我想把它分成令牌,但我如何比较它呢?

split the array on based of operators, then you can compare each term separately.根据运算符拆分数组,然后您可以分别比较每个术语。 even order of terms can be checked.甚至可以检查术语的顺序。 Since this is a string i see no other solution to this.由于这是一个字符串,我看不到其他解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM