Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class node
- {
- public:
- int data,sizee=0;
- node *next;
- node *head=NULL,*temp=NULL;
- void Insert(int x)
- {
- sizee++;
- node *ptr;
- ptr=new node();
- ptr->data=x;
- ptr->next=NULL;
- if(head==NULL)
- {
- head=ptr;
- temp=head;
- }
- else
- {
- temp->next=ptr;
- temp=ptr;
- }
- }
- int Top()
- {
- if(head==NULL) return -1;
- return head->data;
- }
- void pop()
- {
- node *srt=head;
- head=srt->next;
- }
- int Size()
- {
- return sizee;
- }
- };
- class stackk
- {
- public:
- node *top=NULL;
- void Push(int x)
- {
- node *ptr;
- ptr=new node();
- ptr->data=x;
- ptr->next=top;
- top=ptr;
- }
- int Top()
- {
- if(top==NULL) return -1;
- return top->data;
- }
- void pop()
- {
- top=top->next;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment