Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Issues In Database Management A Refernce For The Thinking Practitioner

Authors: Fabian Pascal

1st Edition

0201485559, 978-0201485554

More Books

Students also viewed these Databases questions

Question

Be familiar with the different perspectives of service quality.

Answered: 1 week ago

Question

Describe key customer feedback collection tools.

Answered: 1 week ago

Question

Know what customers expect from the firm when they complain.

Answered: 1 week ago