Guest User

main.cpp

a guest
Jun 14th, 2011
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.09 KB | None | 0 0
  1. //**********************************************************
  2. // Author: D.S. Malik
  3. //
  4. // This program tests the various operations on an ordered
  5. // linked list.
  6. //**********************************************************
  7.  
  8. #include <iostream>                             //Line 1
  9. #include "orderedLinkedList.h"                  //Line 2
  10.  
  11. using namespace std;                            //Line 3
  12.  
  13. int main()                                      //Line 4
  14. {
  15.     orderedLinkedList<int> list1, list2;        //Line 5
  16.     int num;                                    //Line 6
  17.  
  18.     cout << "Line 7: Enter numbers ending "
  19.          << "with -999." << endl;               //Line 7
  20.     cin >> num;                                 //Line 8
  21.  
  22.     while (num != -999)                         //Line 9
  23.     {                                           //Line 10
  24.         list1.insert(num);                      //Line 11
  25.         cin >> num;                             //Line 12
  26.     }                                           //Line 13
  27.  
  28.     cout << endl;                               //Line 14
  29.  
  30.     cout << "Line 15: list1: ";                 //Line 15
  31.     list1.print();                              //Line 16
  32.     cout << endl;                               //Line 17
  33.  
  34.     list2 = list1; //test the assignment operator Line 18
  35.  
  36.     cout << "Line 19: list2: ";                 //Line 19
  37.     list2.print();                              //Line 20
  38.     cout << endl;                               //Line 21
  39.  
  40.     cout << "Line 22: Enter the number to be "
  41.          << "deleted: ";                        //Line 22
  42.     cin >> num;                                 //Line 23
  43.     cout << endl;                               //Line 24
  44.  
  45.     list2.deleteNode(num);                      //Line 25
  46.  
  47.     cout << "Line 26: After deleting "
  48.          << num << ", list2: " << endl;         //Line 26
  49.     list2.print();                              //Line 27
  50.     cout << endl;                               //Line 28
  51.  
  52.     return 0;                                   //Line 29
  53. }                                               //Line 30
Advertisement
Add Comment
Please, Sign In to add comment