c++程序运行问题

来源:百度知道 编辑:UC知道 时间:2024/05/24 03:26:15
我设计一个多项式相加的程序,在运行的时候出现了如图片中的问题,不知道是哪出问题了,希望高手帮我分析指正一下,我的源程序是这样的:

#include<iostream.h>
/*结构声明*/
typedef struct term
{ float coef;
int exp;
struct term *next;
}term,*polynom;
/*多项式相加的实现*/
void add(polynom ah,polynom bh)
{
polynom pa,pb;
polynom pa1,pb1;
pa1=ah;
pb1=bh;
pa=pa1->next;
pb=pb1->next;
while (pa!=NULL&&pb!=NULL)
{if (pa->exp>pb->exp)
{ pa->next=pb;pb1->next=pa;
pa=pa->next;
}
else if(pa->exp<pb->exp)
{ pa->next=pb->next;pb->next=pa;
pb=pb->next;
}
else {pb->coef=pa->coef+pb->coef;
pa=pa->next;pb=pb->next;}
delete ah;
}}
/*输入多项式*/
polynom creat()
{
polynom m,s;
m=new term;
m->next=NULL;
float a;int n,b,c;
cout<<"请输入多项式的项数:"<<endl;
cin>>n;
cou

图片在哪里啊。。以下这个程序在我的电脑上能正常运行哦。
#include<iostream.h>
/*结构声明*/
typedef struct term
{ float coef;
int exp;
struct term *next;
}term,*polynom;
/*多项式相加的实现*/
void add(polynom ah,polynom bh)
{
polynom pa,pb;
polynom pa1,pb1;
pa1=ah;
pb1=bh;
pa=pa1->next;
pb=pb1->next;
while (pa!=NULL&&pb!=NULL)
{if (pa->exp>pb->exp)
{ pa->next=pb;pb1->next=pa;
pa=pa->next;
}
else if(pa->exp<pb->exp)
{ pa->next=pb->next;pb->next=pa;
pb=pb->next;
}
else {pb->coef=pa->coef+pb->coef;
pa=pa->next;pb=pb->next;}
delete ah;
}}
/*输入多项式*/
polynom creat()
{
polynom m,s;
m=new term;
m->next=NULL;
float a;int n,b,c;
cout<<"请输入多项式的项数:"<<endl;
cin>>n;
cout<<"请按指数升序输入多项式的系数和指数:"<<