Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- void push(int x);
- typedef struct alvi
- {
- int data;
- struct alvi *next;
- struct alvi *prev;
- }node;
- node *head=NULL;
- int main()
- {
- push(1);
- push(2);
- push(3);
- return 0;
- }
- void push(int x)
- {
- node *newNode = new node();
- newNode->data = x;
- if(head==NULL)
- {
- cout<<"First node pushed"<<endl;
- newNode->prev=NULL;
- newNode->next=NULL;
- head=newNode;
- }
- else
- {
- cout<<"other node pushed"<<endl;
- newNode->prev=NULL;
- newNode->next=head;
- head= newNode;
- }
- }
Add Comment
Please, Sign In to add comment