So I have a polynomial addition problem like the one below:
(1*x+2*x^3-1*x+7)+(1+1*x^2-1*x+1*x^4)
I need to figure out how to extract the numbers for the coefficients and exponents and enter them into a dynamically allocated 2D array (from here I can sort them and add them together before outputting the answer).
I am pretty lost on how to do this because the polynomials can be in any order of degrees and include any amount of terms. I can dynamically allocate them after I extract all of the numbers. The part I need help on is:
- Extracting all of the numbers
- Differentiating between them to see if it is a coefficient or an exponent
- Allowing this to happen for any number of terms
If anyone could answer this or at least point me in the right direction it would be appreciated.