Advertisement
Guest User

Untitled

a guest
Dec 17th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.19 KB | None | 0 0
  1. #include <iostream>
  2. #include "linked_list.cpp"
  3. #include "ilist.cpp"
  4. using namespace std;
  5.  
  6.  
  7. int main() {
  8.  
  9.     // inicjalizacja
  10.     ilist<long> *lista = new list<long>();
  11.     cout << "declaration done ..." << endl;
  12.     lista->print();
  13.  
  14.     // dodanie elementow
  15.     cout << "pushing three elements back ..." << endl;
  16.     for (int i=0; i<3; i++) {
  17.         lista->push_back(i);
  18.         lista->print();
  19.     }
  20.  
  21.     cout << "pushing three elements front ..." << endl;
  22.     for (int i=-1; -3<=i; i--) {
  23.         lista->push_front(i);
  24.         lista->print();
  25.     }
  26.  
  27.     cout << "pushing element 123 at index 0 ..." << endl;
  28.     lista->insert(123, 0);
  29.     lista->print();
  30.  
  31.     cout << "pushing element 234 at index 1 ..." << endl;
  32.     lista->insert(234, 1);
  33.     lista->print();
  34.  
  35.     cout << "pushing element 777 at index 6 ..." << endl;
  36.     lista->insert(777, 6);
  37.     lista->print();
  38.  
  39.  
  40.     cout << "removing two element from back ..." << endl;
  41.     lista->remove_back();
  42.     lista->print();
  43.     lista->remove_back();
  44.     lista->print();
  45.  
  46.     cout << "removing two element from front ..." << endl;
  47.     lista->remove_front();
  48.     lista->print();
  49.     lista->remove_front();
  50.     lista->print();
  51.  
  52.     // wypisanie
  53.     cout << "printing one last time ..." << endl;
  54.     lista->print();
  55.  
  56.  
  57.     return 0;
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement