you need to do a couple of things...you need to break the expression into tokens, you need to be able to parse each token, you need to know which tokens need to be multiplied by which (i.e. in the expression above, the first 'x' needs to be multiplied by 'x' and '1', but not '0'), and you need to add/combine appropriate tokens (i.e. a 2x and a 3x to get a 5x).
I've probably missed a few things, but this is where I'd start. Once you get some of these parts done, you can start assembling it into your final program.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Clowns were never meant to be THAT big! We must destroy it with this tiny ad: