Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- typedef struct mylist
- {
- int data;
- struct mylist *next;
- struct mylist *prev;
- }node;
- int main()
- {
- node*a= (node*)malloc(sizeof(node));
- node*b= (node*)malloc(sizeof(node));
- node*c= (node*)malloc(sizeof(node));
- a->data=7;
- b->data=2;
- c->data=6;
- a->next=b;
- b->next=c;
- c->next=NULL;
- c->prev=b;
- b->prev=a;
- a->prev=NULL;
- printf("The forward list: \n");
- while(a!=NULL)
- {
- printf("%d\n",a->data);
- a=a->next;
- }
- printf("NULL\n");
- printf("The backward list: \n");
- while(c!=NULL)
- {
- printf("%d\n",c->data);
- c=c->prev;
- }
- printf("NULL\n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement