write a complete program to implement 2-polynomials using singly linked list then add 2-polynomials and print the result
p1=2x^2+x+5
p2=4x^3+2x+1
p1+p2=p3
p3=4x^3+2x^2+3x+6
محاولتي
#include <iostream.h>
struct node
{
float coef;
float exp;
node *next;
};
void insert_node(node **R,node *N)
{
if(*R==NULL)
*R=N;
else
{
N->next=*R;
*R=N;
}
}
void main()
{
node *p1,*p2,*p3,*N;
do{
N=new node;
N->next=NULL;
cout <<"CoEf ";
cin>>N->coef;
cout<<"Exp ";
cin>>N->exp;
insert_node(&p1,N);
}while(p1->exp!=0);
do{
N=new node;
N->next=NULL;
cout <<"CoEf ";
cin>>N->coef;
cout<<"Exp ";
cin>>N->exp;
insert_node(&p2,N);
}while(p2->exp!=0);
}ممكن تساعدوني باخر خطوة كيف يتم جمع المعادلتين