Here's your simple pseudocode:
No error checking for one polynomial running out before the other, of course. The above would be massaged slightly depending on whether the Poly structure/classes were fully populated sparse descriptions or included only non-zero coefficient terms.Code:int i; if (myPoly1.numTerms != myPoly2.numTerms) return false; for (i = 0; i < myPoly1.numTerms; i++) { if (myPoly1[i].coefficient != myPoly2[i].coefficient || myPoly1[i].power != myPoly2[i].power) return false; } return true;




Reply With Quote