- typedef struct node
- { int data;
- struct node *next;
- }JD;
- JD *interset(JD *la, JD *lb)
- { JD *lc, *p, *q, *r;
- p=la;
- q=lb;
- lc=(JD *)malloc(sizeof(JD));
- r=lc;
- while((p!=NULL) && (q!=NULL))
- { if (p->data > q->data)
- q=q->next;
- else if (p->data < q->data)
- p=p->next;
- else
- { r->next=(JD *)malloc(sizeof(JD));
- r=r->next;
- r->data=p->data;
- p=p->next;
- q=q->next;
- }
- }
- r->next=NULL;
- u=lc;
- lc=lc->next;
- free(u);
- return(lc);
- }