What I would like to do is have the first pass go through to check deg and put it into lowest to highest…Then do the second pass and do the coef and put that lowest to highest.
I’m getting segmentation fault…I was wondering if the two if statements is even possible
Poly merge(Poly* plist1,Poly* plist2){
Term **pp;
Poly merged,list1,list2;
merged = new_Term(); //function for new term in another file
list1 = *plist1;
list2 = *plist2;
pp= &merged;
while(list1 != NULL && list2 != NULL){
if(list2->deg < list1->deg)
{
*pp = list1;
list1 = list1->next;
(*pp)->next = NULL;
}
else
{
*pp = list2;
list2 = list2->next;
(*pp)->next = NULL;
}
if(list2->coef < list1->coef)
{
*pp = list1;
list1 = list1->next;
(*pp)->next = NULL;
}
else
{
*pp = list2;
list2 = list2->next;
(*pp)->next = NULL;
}
pp = &( (*pp)->next );
}
if(list1 != NULL)
*pp = list1;
if(list2 != NULL)
*pp = list2;
*plist1 = NULL;
*plist2 = NULL;
return merged;
}
NVM I think I found my problem…I needed to make it into an if…else if statement and delete one of the
blocks
Thanks anyways for those fast responders
Update:
Also I needed to change
To