按要求输入后没有输出,然后显示Process exited...return value 3221225477,请问是为什么?

图片说明

#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
#include<math.h>
#include<string.h>
typedef struct node
{
    int coe;
    int pow;
    struct node *pNext;
}NODE,*PNODE;

PNODE input()
{
    int a,n;
    char c;
    PNODE pHead,p,q,p0;
    pHead = p = NULL;
    do {  //创建一个链表存放第一个多项式
        scanf("%d%d%c", &a, &n, &c);
        if( pHead == NULL) 
             pHead = p = (NODE*)malloc(sizeof(NODE));
       else {
            p->pNext = (NODE*)malloc(sizeof(NODE));
            p = p->pNext;
       }
       p->coe = a; p->pow = n; p->pNext = NULL;
     } while ( c != '\n');
    return pHead;
}
PNODE samepow()//相同指数系数相加
{
    PNODE pHead,p1,p2,p3;
    p1=pHead;
    p2=p1->pNext;
    p3=(NODE *)malloc(sizeof(NODE));
    while(p1!=NULL)
    {
        while(p2!=NULL)
        {
            if(p1->pow==p2->pow)
            {
                p3=p2->pNext;
                p1->coe+=p2->coe;
                p1->pNext=p2->pNext;
                free(p3);
            }
            p2=p2->pNext;
        }
        p1=p1->pNext;
    }
    return pHead;
}
PNODE operate(PNODE a,PNODE b)//相乘操作
{
    PNODE p1=a;
    PNODE p2=b;
    PNODE p3,pNew,pHead;
    p3=pNew=(NODE *)malloc(sizeof(NODE));
    pHead=p3;
    pHead->pNext=NULL; 
    while(p1!=NULL)
    {
        while(p2!=NULL)
        {
            p3->coe=p1->coe*p2->coe;
            p3->pow=p1->pow+p2->pow;
            p2=p2->pNext;
            pNew=p3;
            p3=(NODE *)malloc(sizeof(NODE));
            pNew->pNext=p3;
        }
        p1=p1->pNext;
        p2=b;
    }
    pNew->pNext=NULL;
    return pHead;
}
int main()
{
    PNODE multi1;
    PNODE multi2;
    multi1=input();
    multi2=input();
    PNODE pNew=(NODE *)malloc(sizeof(NODE));
    pNew=operate(multi1,multi2);
    PNODE px,py,tmp,tmp1;
    px=pNew;
    py=px->pNext;
    while(px!=NULL)
    {
        while(py!=NULL)
        {
            if(px->pow<py->pow)
            {
                tmp->pow=py->pow;tmp1->coe=py->coe;
                py->pow=px->pow;py->coe=px->coe;
                px->pow=tmp->pow;py->coe=tmp1->coe;
            }
            py=py->pNext;
        } 
        px=px->pNext;
        py=px->pNext;
    }//按指数从高到低排序
    PNODE multi3=(NODE *)malloc(sizeof(NODE));
    multi3=samepow(pNew);
    PNODE q=multi3;
    for(q=multi3;q!=NULL;q=q->pNext)
    {
        printf("%d %d ",q->coe,q->pow);
    }//输出
    return 0;
}
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问