/*the correct way to delete a table*//*Assume header*/voiddeletelist (List L) {Position p,tmp; P=l->Next; while(P! =NULL) {TMP=p->Next; Free(P); P=Tmp; }}//first free, and then determine if the node next is null, is not to do/*Multi-item ADT*//*type declaration of a polynomial array implementation*//*A structure can be represented. A polynomial*/typedefstruct{Coeffarray[maxdegree+1]; intHighpower;//represents the highest time of the array} *polynomial;/*initialize the polynomial to 0*/voidzeropolynomial (polynomial Poly) { for(i=0; I <= maxdegree; i++) {Poly->coeffarray[i]=0; } Poly->highpower =0;}/*two the process of adding a polynomial*/voidaddpolynomial (polynomial poly1,polynomial poly2,polynomial polysum) {zeropolynomial (PolySum); Maxpower=MAX2 (poly1->highpower,poly2->highpower); for(i=0; i<=maxpower;i++) {polysum->coeffarray[i] = Poly1->coeffarray[i] + poly2->Coeffayyay[i]; } polysum->highpower=Maxpower;}/*the process of multiplying two polynomial*/voidmultpolynomial (polynomial poly1,polynomial poly2,polynomial polyprod) {zeropolynomial (PolyProd); Polyprod->highpower = Poly1->highpower * poly2->Highpower; for(intI=0; I <= poly1->highpower; i++) { for(intj=0; J <= poly2->highpower; J + +) {Polyprod->COEFFARRAY[I+J] + = poly1->coeffarray[i] * poly2->Coeffarray[j]; } }}
View Code
Multi-item ADT