数据结构线性表输入好像有问题

求大佬们帮忙看一下吧,我的输入好像就有问题,输入不了

#include<stdio.h>
#include<stdlib.h>
typedef struct LNode{
    int coef;
    int expn;
    struct LNode *next;
    struct LNode *prior;
}LNode,*LinkList;
int compete(int a,int b){
    if(a<b)return -1;
    else if(a==b)return 0;
    else if(a>b)return 1;
}
void AddPolyn(LinkList A,LinkList B,int m,int n){
    while(A&&B){
        switch(compete(A->expn,B->expn)){
            case -1:A=A->next;break;
            case 0:A->coef=A->coef+B->coef;A=A->next;B=B->next;break;
            case 1:A->prior->next=B;B->prior=A->prior;B=B->next;break;
        }
    }
    while(B!=NULL){
        A->next=B;
        B=B->next;
    }
}
void MinusPolyn(LinkList A,LinkList B,int m,int n){
    while(A&&B){
        switch(compete(A->expn,B->expn)){
            case -1:A=A->next;break;
            case 0:A->coef=A->coef-B->coef;A=A->next;B=B->next;break;
            case 1:B->coef=-B->coef;A->prior->next=B;B->prior=A->prior;B=B->next;break;
        }
    }
    while(B!=NULL){
        B->coef=-B->coef;
        A->next=B;
        B=B->next;
    }
}
int main(){
    int m,n,t,i,j;
    LinkList A=NULL,B=NULL;
    LinkList p=NULL;
    scanf("%d%d%d",&m,&n,&t);
    for(i=0;i<2*m;i++){
        p=(LinkList)malloc(sizeof(LinkList));
        scanf("%d%d",&p->coef,&p->expn);
        A->next=p;
        A=p;
    }
    for(i=0;i<2*n;i++){
        p=(LinkList)malloc(sizeof(LinkList));
        scanf("%d%d",&p->coef,&p->expn);
        B->next=p;
        B=p;
    }
    if(t=0)AddPolyn(A,B,m,n);
    else if(t=1)MinusPolyn(A,B,m,n);
    while(A){
        if(A->coef==0)A=A->next;
        if(A->expn==0)printf("%d",A->coef);
        else if(A->expn==1){
            if(A->coef>0)printf("+%dx",A->coef);
            else if(A->coef<0)printf("%dx",A->coef);
        }
        else if(A->expn>1){
            if(A->coef>0)printf("+%dx^%d",A->coef,A->expn);
            else if(A->coef<0)printf("%dx^%d",A->coef,A->expn);
        }
    }
    return 0;
} 
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问