(续)


struct polynomial *addpolynomial(struct polynomial *heada,struct polynomial *headb)  //Ò»Ôª¶àÏîʽÏà¼Ó
{
    struct polynomial *pa;
    struct polynomial *pb;
    struct polynomial *flagb;
    if(heada==NULL || headb==NULL)return NULL;
    pa=heada;
    pb=headb;
w:  while(pa!=NULL && pb!=NULL)
    {
      if(pa->expn==pb->expn)
      {
          pa->coef=pa->coef+pb->coef;
          pb=pb->next;
          goto w;
      }
      if(pa->expn<pb->expn)
      {
          if(pa->next==NULL)
          {
              pa->next=pb;
              break;
          }
          if(pa->next->expn>pb->expn)
          {
              flagb=pb->next;
              pb->next=pa->next;
              pa->next=pb;
              pb=flagb;
              pa=pa->next;
              goto w;
          }
          if(pa->next->expn<=pb->expn)
          {
              pa=pa->next;
              goto w;
          }
      }
      if(pa->expn>pb->expn)
      {
            flagb=pb->next;
            pb->next=pa;
            if(pa==heada)heada=pb;
            pa=pb;
            pb=flagb;
            goto w;
      }
    }
    if(pa==NULL && pb!=NULL)
    {
        pa=heada;
        while(pa->next!=NULL)
        {
            pa=pa->next;
        }
        pa->next=pb;
    }
return(heada);
}
void main()
{
     struct polynomial *heada;
     struct polynomial *headb;
     cout<<"&Ccedil;&euml;&Ecirc;&auml;&Egrave;&euml;&micro;&Uacute;&Ograve;&raquo;&cedil;&ouml;&Ograve;&raquo;&Ocirc;&ordf;&para;à&Iuml;&icirc;&Ecirc;&frac12;&micro;&Auml;&Iuml;&micro;&Ecirc;&yacute;&ordm;&Iacute;&Ouml;&cedil;&Ecirc;&yacute;&pound;&not;&Ograve;&Ocirc;&Iuml;&micro;&Ecirc;&yacute;&ordm;&Iacute;&Ouml;&cedil;&Ecirc;&yacute;&frac34;ù&Icirc;&ordf;0×÷&Icirc;&ordf;&frac12;á&Ecirc;&oslash;±ê&Ouml;&frac34;&pound;&ordm;\n";
     heada=create_polynomial(heada);
     cout<<"&Ccedil;&euml;&Ecirc;&auml;&Egrave;&euml;&micro;&Uacute;&para;&thorn;&cedil;&ouml;&Ograve;&raquo;&Ocirc;&ordf;&para;à&Iuml;&icirc;&Ecirc;&frac12;&micro;&Auml;&Iuml;&micro;&Ecirc;&yacute;&ordm;&Iacute;&Ouml;&cedil;&Ecirc;&yacute;&pound;&not;&Ograve;&Ocirc;&Iuml;&micro;&Ecirc;&yacute;&ordm;&Iacute;&Ouml;&cedil;&Ecirc;&yacute;&frac34;ù&Icirc;&ordf;0×÷&Icirc;&ordf;&frac12;á&Ecirc;&oslash;±ê&Ouml;&frac34;&pound;&ordm;\n";
     headb=create_polynomial(headb);
     if (heada==NULL && headb!=NULL)
     {
         headb=resort(headb);
         print(headb);
     }
     if (headb==NULL && heada!=NULL)
     {
         heada=resort(heada);
         print(heada);
     }
     if (headb==NULL && heada==NULL)cout<<"0"<<endl;
     if((headb!=NULL && heada!=NULL))
     {
         heada=resort(heada);
         headb=resort(headb);
         heada=addpolynomial(heada,headb);
         print(heada);
     }
}