main.cpp 963 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Project: Doubly_Linked_List.cbp
  2. // File : main.cpp
  3. #include <iostream>
  4. #include "DoublyNode.h"
  5. #include "DoublyLinkedList.h"
  6. using namespace std;
  7. int main()
  8. {
  9. // NULL
  10. DoublyLinkedList<int> linkedList = DoublyLinkedList<int>();
  11. // it will be printed backwardly
  12. // 43->NULL
  13. linkedList.InsertHead(43);
  14. // 43->76->NULL
  15. linkedList.InsertHead(76);
  16. // 15->43->76->NULL
  17. linkedList.InsertTail(15);
  18. // 44->15->43->76->NULL
  19. linkedList.InsertTail(44);
  20. // Print the list element
  21. cout << "First Printed:" << endl;
  22. linkedList.PrintListBackward();
  23. cout << endl;
  24. // 100->44->15->43->76->NULL
  25. linkedList.Insert(4, 100);
  26. // 100->44->48->15->43->76->NULL
  27. linkedList.Insert(3, 48);
  28. // 100->44->48->15->43->76->22->NULL
  29. linkedList.Insert(0, 22);
  30. // Print the list element
  31. cout << "Second Printed:" << endl;
  32. linkedList.PrintListBackward();
  33. cout << endl;
  34. return 0;
  35. }