SilverhandX

list main2.cpp

Feb 24th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.32 KB | None | 0 0
  1. #include<iostream>
  2. #include "list.h"
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     List l;
  8.  
  9.     l.appendNode(6);
  10.     l.appendNode(19);
  11.     l.appendNode(21);
  12.  
  13.     //Display initial values
  14.     cout << "Here are the initial values:\n";
  15.     l.displayList();
  16.     cout << endl;
  17.  
  18.     //Delete middle node
  19.     cout << "Now deleting the node in the middle.\n";
  20.     l.deleteNode(19);
  21.  
  22.     //Display the list
  23.     cout << "Here are the nodes left:\n";
  24.     l.displayList();
  25.     cout << endl;
  26.  
  27.     //Insert new middle node
  28.     cout << "Inserting a new node in the middle:\n";
  29.     l.insertNode(11);
  30.  
  31.     //Display the list
  32.     cout << "Here is the new list:\n";
  33.     l.displayList();
  34.     cout << endl;
  35.  
  36.     //Using insertSpecificNode to put a node in a place that's not numerical order
  37.     cout << "Inserting a new node between 6 and 11:\n";
  38.     l.insertSpecificNode(74, 1);
  39.     cout << endl;
  40.  
  41.     //Display the list
  42.     cout << "Here is the new list:\n";
  43.     l.displayList();
  44.     cout << endl;
  45.  
  46.     //Using a high value to show that insertSpecificNode puts the node at the end of the list if the place requested does not exist
  47.     cout << "Inserting a new node at the end of the list:\n";
  48.     l.insertSpecificNode(2, 9999);
  49.     cout << endl;
  50.  
  51.     //Display the list
  52.     cout << "Here is the new list:\n";
  53.     l.displayList();
  54.     cout << endl;
  55.  
  56.     return 0;
  57. }
Add Comment
Please, Sign In to add comment