Advertisement
_Kripaka001_

linkedList 5

Aug 18th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5.  class List{
  6.     public:
  7.  
  8.         List(){ next = NULL; data = 0;}
  9.         int data;
  10.         List* next;
  11.  };
  12.  
  13.  int pop(List* x){ // delete one from the end and type data ||-||-/  *5*
  14.     return x->data;
  15.  }
  16.  
  17.  void push (List* root, int value){     // insert line to the end ||-||-|new|
  18.     List *node = new List();
  19.     node->data = value;
  20.     node->next = root;
  21.     root = node;
  22.     cout << root->data << endl;
  23. }
  24.  
  25.  int main(){
  26.     List root;
  27.     push(&root, 10);
  28.     cout << root.data << endl;
  29.     cout<< pop(&root);
  30.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement