#include #include #include void Removerep(); struct node { int no; struct node *next; }; struct node *start=NULL,*start1=NULL ,*start2=NULL; void Append(struct node *p) { struct node *n; n=(struct node*)malloc(sizeof(struct node)) ; printf("\n enter no."); scanf("%d",&n->no); n->next=NULL; if(p==NULL) { if(p==start) start=n; else start1=n; return; } while(p->next!=NULL) { p=p->next; } p->next=n; } void AppendInter(struct node*p,int a) { struct node *n; n=(struct node*)malloc(sizeof(struct node)); n->no=a; n->next=NULL; if(p==NULL) { start2=n; return; } while(p->next!=NULL) { if(p->no==a) return; p=p->next; } if(p->no==a) return; p->next=n; } void Traverse(struct node *p) { if(p==NULL) { printf("link list empty"); return; } while(p!=NULL) { printf("\t %d",p->no); p=p->next; } } void Intercect() { struct node *p,*q; for(p=start;p!=NULL;p=p->next) { for(q=start1;q!=NULL;q=q->next) { if(p->no==q->no) { AppendInter(start2,q->no); } } } } void main() { int ch; clrscr(); do { printf("\n\n\n 1 Append in LINKLIST 1"); printf("\n 2 Append in LINKLIST 2"); printf("\n 3 INTERSECT the LINK LIST"); printf("\n 4 TRaverse LINK list 1"); printf("\n 5 Traverse LINK List 2"); printf("\n 6 Traverse LINK list 3"); printf("\n 0 exit"); printf("\nenter your choice"); scanf("%d",&ch); switch(ch) { case 1: Append(start); break; case 2: Append(start1); break; case 3: Intercect(); break; case 4: Traverse(start); break; case 5: Traverse(start1); break; case 6: Traverse(start2); break; case 0: break; default: printf("\n invalid choice"); } }while(ch!=0); getch(); }