#include struct list { int pow,coef; struct list *next; }; typedef struct list node; typedef node *link; link find(link h,int c, int p) { link ptr; ptr=h; do { if ((ptr->coef == c) && (ptr->pow == p)) return ptr; ptr=ptr->next; } while (ptr != h); return NULL; } void print_poly(link head) { link pt1; printf("the input polynomial ---> f(X)="); pt1=head; do { if (pt1->pow != 0) printf("%2dX%2d",pt1->coef,pt1->pow); else printf("%2d",pt1->coef); pt1=pt1->next; if (pt1 != head) printf("+"); } while (pt1 != head); printf("\n"); } link create() { int c,p; link head,pt1,pt2; head=NULL; while (1) { printf("give me poly ?"); scanf("%d %d",&c,&p); if ((c == 0) && (p == 0)) break; pt2=(link)malloc(sizeof(node)); if (head == NULL) pt1=head=pt2; else pt1=pt1->next=pt2; pt2->coef=c; pt2->pow=p; } pt2->next=head; return head; } link conpoly(link h1,link h2) { link pt1,pt2; int c,p; pt1=h1; while (pt1->next != h1) pt1=pt1->next; pt1->next=h2; pt1=h2; while (pt1->next != h2) pt1=pt1->next; pt1->next=h1; return h1; } void main() { link h1,h2; printf("give me the first polynomial -->"); h1=create(); print_poly(h1); h2=create(); print_poly(h2); h1=conpoly(h1,h2); print_poly(h1); }