###### 洗河
2019-03-28 09:23 阅读 1.0k

# 按要求输入后没有输出，然后显示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;
do {  //创建一个链表存放第一个多项式
scanf("%d%d%c", &a, &n, &c);
else {
p->pNext = (NODE*)malloc(sizeof(NODE));
p = p->pNext;
}
p->coe = a; p->pow = n; p->pNext = NULL;
} while ( c != '\n');
}
PNODE samepow()//相同指数系数相加
{
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;
}
}
PNODE operate(PNODE a,PNODE b)//相乘操作
{
PNODE p1=a;
PNODE p2=b;
p3=pNew=(NODE *)malloc(sizeof(NODE));
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;
}
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;
}
``````
• 点赞
• 写回答
• 关注问题
• 收藏
• 复制链接分享