Академический Документы
Профессиональный Документы
Культура Документы
printf("enter the element after which u want to insert the node"); scanf("%d",&num); ptr=start; while(ptr!=NULL) { if((num!=ptr->info)&&(ptr!=NULL)) { ptr=ptr->next; }
else if((num==ptr->info)&&(ptr!=NULL)) { n=(nodetype *)malloc(sizeof(nodetype)); printf("info u want to insert"); scanf("%d",&item);
n->info=item; n->next=ptr->next; ptr->next=n; ptr=n; printf("node is being inserted with info %d",ptr->info); break; } if(ptr==NULL) { printf("element is not present"); } getch();
ptr=start; Printf(enter the item which u want to delete); Scanf(%d,&item); If(start==NULL) { printf("list is empty and Item not in the list"); break; } else if(start->info==item) { save=NULL; ptr=start; start=ptr->next; free(ptr); Break; }
typedef struct node { int info; struct node *next; struct node *prev; }nodetype; void main() { char opt; nodetype *r,*l,*start=NULL,*n; int num; clrscr(); do{ printf("\nEnter the info u want to enter"); scanf("%d",&num);
n=(nodetype *)malloc(sizeof(nodetype)); if(start==NULL) { start=n; r=n; l=n; l->info=num; l->next=NULL; l->prev=NULL; } else { l->next=n; l=n; l->info=num; l->next=NULL; l->prev=r; r=n; }
INFO[PTR] LINK[PTR]
Ptr->info Ptr->next
PTR=LINK[PTR]
INFO[PTR]=NUM PTR= NEW LINK[PTR]=NEW
Ptr=ptr->next
Ptr->info = num Ptr=new Ptr->next=new
LINK[NEW]=LINK[SAVE New->next=save->next ]