Multi-item ADT

Source: Internet
Author: User

/*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-&GT;COEFFARRAY[I+J] + = poly1->coeffarray[i] * poly2->Coeffarray[j]; }    }}
View Code

Multi-item ADT

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.