How to split a mathematical equation into coefficients and exponents?

I am computing some equations in java. I want to use single linked list. Nodes should have two integer data: coefficient and exponent.

equation = 18x^75-4x^56+18x^37+18x^19-18x^9-12

linked list= node1(18, 75)->node2(-4, 56)...

I am asking just splitting.

sorry for bad English.

String equation = "18x^75-4x^56+18x^37+18x^19-18x^9-12";

String[] terms = equation.split("[0-9]+(?<=[-+*/()])|(?=[-+*/()])");

for (String term : terms) {

System.out.println(term);

}...

Read More »

By: StackOverFlow - Sunday, 11 March

Related Posts