u010940902 于 2013.06.10 21:43 提问

#include
#include
struct PolyNode
{
float coef;
int exp;
PolyNode * next;
};
//template
{
public:
void ShowList();
private:
};
//---------------------------------------------------------------------------
//template
{
int i=0;
for(i=0;i {
PolyNode * s=new PolyNode;
s->coef=a[i];
s->exp=i;
q->next=s;
q=q->next;
}
}
//template
{
while(p->next)
{
PolyNode * q=p;
p=p->next;
delete q;
}
}
//template
{
while(p->next!=NULL)
{
cout<next->coef<<"*E"<next->exp;
if(p->next->next!=NULL)
cout<<"+";
//cout< p=p->next;
}
cout< }
//template
{
float sum;
PolyNode * pa,* pb,* qa,* qb;
qa=pa->next;
qb=pb->next;
while(qa!=NULL&&qb!=NULL)
{
if(qa->expexp)
{
pa=qa;
qa=qa->next;
}
else if(qa->exp>qb->exp)
{
pb->next=qb->next;
qb->next=qa;
pa->next=qb;
pa=qb;
qb=pb->next;
}
else
{
sum=qa->coef+qb->coef;
if(sum==0)
{
pa->next=qa->next;
delete qa;
pb->next=qb->next;
delete qb;
qb=pb->next;
}
else
{
qa->coef=sum;
pa=qa;
qa=qa->next;
pb->next=qb->next;
delete qb;
qb=pb->next;
}
}
}
if(qb!=NULL)
qa->next=qb;
}
{
while(p->next)
{
cout<next->coef<<"*E"<next->exp;
if(!(p->next->next))
cout<<"+";
}
}*/
//-------------------------------------------------------------------------------------
void main()
{
float a[5]={1.0,2.0,3.0,4.0,5.0};
str.ShowList();
float b[5]={6.0,7.0,8.0,9.0,0};
str.ShowList();
system("pause");
}

1个回答

wangyaninglm      2015.01.15 23:53