简体   繁体   中英

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? 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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