Question
I am mainly concerned on how to extract the polynomials into arrays so they can be sorted and added or multiplied together. If you could
I am mainly concerned on how to extract the polynomials into arrays so they can be sorted and added or multiplied together. If you could get the whole code that would be great but if not some help on the dynamic allocation of the arrays would be great.
Special Grading Considerations: If your code doesn't compile or if you use (non-constant) global variables, the best you can do is a C. You will process a file that contains a sequence of strings representing polynomial arithmetic. Each line of the file will consist of a string that contains two polynomials that are to be added or multiplied. Each polynomial will be contained in parentheses and they will be separated by the appropriate operator. For example, (1*x+2*x^3-1*x+7)+(1+1*x^2-1*x+1*x^4) or (1*x+2*x^3-1*x+7)*(1+1*x^2-1*x+1*x^4) Facts about the input string: The string will contain no spaces. The terms may not be in order of degree. A term with coefficient 1 will have the 1 present. The coefficients will always be integers. Zero will never appear as a coefficient. Each file will contain some unspecified number of strings (one per line) that meet the above criteria. The program should read in each problem as a whole and then break it into two polynomials. The terms of the operands may be stored in the order they are specified. After the appropriate operation is performed, the polynomial must be sorted from highest degree to smallest and displayed to the console. If you would like to be eligible for full credit, the display must look like a typical polynomial: 5 3 3x + x - 12x + 7 You may opt to output in the format of the input 3*x^5+x^3-12*x+7 but that will cap your grade at 90. A polynomial will be a dynamically allocated two dimensional arrays where each row represents a monomial and each row has two columns: the first is the exponent and the second is the coefficient. That is, a polynomial will be declared as int ** polynomial; You should define a function per operation; i.e. int** add(int **left, int **right) int** mutliply(int **left, int **right) and have another operation that parses a string to extract one polynomial: int** getPolynomial(string polynomial).
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started