我想做的是让第一次通过检查 deg 并将其放入最低到最高...然后进行第二次通过并进行 coef 并将最低到最高。
我遇到分段错误...我想知道这两个 if 语句是否可能
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;
}