怎么实现两个多项式的除法(用链表实现)???
void polyChu(polynode *A,polynode *B)polyptr P = A, Q,L,R,T,C,D;
polyptr COPYA = NULL,COPYB = NULL;
if(A->xishu == 0){
printf("0.\n");
return ;
}
if(B->xishu == 0){
printf("除数为0,错误!\n");
return ;
}
if(A->xishu < B->xishu){
printf("商:0,余数为:");
display(A);
return ;
}
while(NULL != P){
Q = (polyptr)malloc(sizeof(polynode));
Q->xishu = P->xishu;
Q->zhishu = P->zhishu;
Q->next = NULL;
if(NULL == COPYA)
COPYA = Q;
else
L->next = Q;
L = Q;
P = P->next;
}
P = B;
while(NULL != P){
Q = (polyptr)malloc(sizeof(polynode));
Q->xishu = -(P->xishu);
Q->zhishu = P->zhishu;
Q->next = NULL;
if(NULL == COPYB)
COPYB = Q;
else
L->next = Q;
L = Q;
P = P->next;
}
C = P = Q = L = R = T = NULL
while(COPYA->zhishu >= COPYB->zhishu){
D = COPYA;
while(NULL != D->next)
D = D->next;
R = COPYB;
Q = (polyptr)malloc(sizeof(polynode));
Q->xishu = (-COPYA->xishu) / R->xishu;
Q->zhishu = COPYA->zhishu - R->zhishu;
Q->next = NULL;
if(NULL == L)
L = Q;
else
P->next = Q;
P = Q;
while(NULL != R){
Q = (polyptr)malloc(sizeof(polynode));
Q->xishu = P->xishu * R->xishu;
Q->zhishu = P->zhishu + R->zhishu;
Q->next = NULL;
if(NULL == T)
T = Q;
else
C->next = Q;
C = Q;
R = R->next;
}
D->next = T;
T = NULL;
C = NULL;
}
printf("A除以B,商:");
display(L);
printf("余数:");
display(COPYA); 请问这个程序怎么才能更完善一下???谢谢了