Double Linked List
Double Linked List
#include <stdio.h>
#include <stdlib.h>
struct node
int data;
struct node*pre;
} *stnode;
void creatlikedlist(int n)
int num;
if (stnode == NULL)
else
scanf("%d", &num);
stnode->data = num;
// stnode->next = NULL;
tmp = stnode;
if (fnnode == NULL)
break;
else
scanf("%d", &num);
fnnode->data = num;
fnnode->next = NULL;
tmp->pre=fnnode;
tmp->next = fnnode;
tmp = tmp->next;
void display()
struct node*ptr;
if(stnode==NULL){
printf("memory is emty");
else{
ptr=stnode;
while(ptr!=NULL)
{
printf("\ndata=%d",ptr->data);
ptr=ptr->next;
struct node*new_node;
int num;
scanf("%d",&num);
new_node->data=num;
new_node->next=stnode;
new_node->pre=NULL;
stnode=new_node;
return stnode;
struct node*new_node,*ptr;
int num;
scanf("%d",&num);
new_node->data=num;
ptr=stnode;
while(ptr->next!=NULL){
ptr=ptr->next;
}
ptr->next=new_node;
new_node->pre=ptr;
new_node->next=NULL;
return stnode;
stnode=stnode->next;
stnode->pre=NULL;
return stnode;
struct node*ptr,*prev;
ptr=stnode;
while(ptr->next!=NULL){
ptr=ptr->next;
ptr->pre->next=NULL;
return stnode;
int main()
int n;
scanf("%d",&n);
creatlikedlist(n);
display();
stnode=insertAtbeginning(stnode);
display();
stnode=insertAtlast(stnode);
display();
stnode=deleteAtbeg(stnode);
display();
stnode=deleteAtend(stnode);
display();
return 0;