C++ Linked list problem, computer science homework help
C++ Linked list problem, computer science homework help
According to the file that i uploaded, I have to write add polynomial function
so far I wrote like this and it does not work
how can I fix this code?
void add (List &polyZ, List &polyF, List &poly G)
{
Node *pN_Z,*pN_F;
int icoeff,ideg;
head=ptrn= ptrp = NULL;
pN_Z =Z.head;
pN_F =F.head;
while(pN_Z!=NULL && pN_F=NULL)
{
if(pN_Z->ideg==pN_F->ideg) // deg is equal
{
icoeff=pN_Z->icoeff+pN_F->icoeff;
ideg=pN_Z-> ideg;
pN_Z= pN_Z->next;
pN_F= pN_F->next;
}
else if(pN_Z->ideg > pN_F->ideg)
{
icoeff = pN_Z->icoeff;
ideg = pN_Z->ideg;
pN_Z = pN_Z->next;
}
else if(pN_Z->ideg <pN_F->ideg)
{
icoeff = pN_F->icoeff;
ideg = pN_F->ideg;
pN_F = pN_F->next;
}
ptrn=new node;
if(head==NULL)
head =ptrn;
ptrn->icoeff= icoeff;
ptrn-> ideg= ideg ;
ptrn-> next=NULL;
ptrp->next=ptrn;
ptrp=ptrn;
} // End of While
if(pN_Z==NULL)
{
while(pN_F!=NULL)
{
icoeff =pN_F->icoeff;
ideg = pN_F->ideg;
pN_F= pN_F->next;
ptrn=new node;
if(head==NULL)
head=ptrn;
ptrn->icoeff=icoeff;
ptrn->ideg=ideg;
ptrn->next=NULL;
ptrp->next=ptrn;
ptrp=ptrn;
}
}
else if(pN_F==NULL)
{
while(pN_Z!=NULL)
{
icoeff =pN_Z->icoeff;
ideg = pN_Z->ideg;
pN_Z= pN_Z->next;
ptrn=new node;
if(head==NULL)
head=ptrn;
ptrn->icoeff=icoeff;
ptrn->ideg=ideg;
ptrn->next=NULL;
ptrp->next=ptrn;
ptrp=ptrn;
}
}
} // End of addition
"You need a similar assignment done from scratch? Our qualified writers will help you with a guaranteed AI-free & plagiarism-free A+ quality paper, Confidentiality, Timely delivery & Livechat/phone Support.
Discount Code: CIPD30
Click ORDER NOW..


