SHARE
TWEET

LL Help (C++) Main Programs

a guest Dec 14th, 2019 105 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //MAIN 1
  2.  
  3. int main() {
  4.  
  5.    LL ll1;
  6.    cout << "length of empty list - " << ll1.list_length() << endl;
  7.    ll1.display_list();
  8.    ll1.push_front("aaaaa");
  9.    ll1.push_back("bbbbb");
  10.    ll1.push_front("before aaaaa");
  11.    ll1.push_back("after bbbbb");
  12.    cout << "length of list after 4 pushes - " << ll1.list_length() << endl;
  13.    ll1.display_list();
  14.    cout << endl;
  15.  
  16.    LL ll2;
  17.    ll2.push_front("33333");
  18.    ll2.push_front("22222");
  19.    ll2.push_front("11111");
  20.    ll2.push_back("44444");
  21.    ll2.push_back("55555");
  22.    ll2.push_back("66666");
  23.    ll2.display_list();
  24.  
  25.    return 0;
  26. }
  27.  
  28. //MAIN 2
  29.  
  30. int main() {
  31.  
  32.    LL ll1;
  33.    cout << "main: length of empty list - " << ll1.list_length() << endl;
  34.    cout << "main: trying to display empty list 1" << endl;
  35.    ll1.display_list();
  36.    cout << "main: trying to display initial size of ll1 - " << ll1.list_length() << endl;
  37.    ll1.push_front("aaaaa");
  38.    ll1.push_back("bbbbb");
  39.    ll1.push_front("before aaaaa");
  40.    ll1.push_back("after bbbbb");
  41.    cout << "main: length of ll1 after 4 pushes - " << ll1.list_length() << endl;
  42.    cout << "main: now trying to display ll1 after 4 push's" << endl;
  43.    ll1.display_list();
  44.    cout << "main: displaying final size of ll1 - " << ll1.list_length() << endl;
  45.    cout << endl;
  46.  
  47.    LL ll2;
  48.    ll2.push_front("33333");
  49.    ll2.push_front("22222");
  50.    ll2.push_front("11111");
  51.    ll2.push_back("44444");
  52.    ll2.push_back("55555");
  53.    ll2.push_back("66666");
  54.    cout << "main: now trying to display ll2 after 6 push's" << endl;
  55.    ll2.display_list();
  56.  
  57.    return 0;
  58. }
  59.  
  60. //MAIN 3
  61.  
  62. int main() {
  63.  
  64.    LL ll1;
  65.    cout << "main: length of empty list - " << ll1.list_length() << endl;
  66.    cout << "main: trying to display empty list 1" << endl;
  67.    ll1.display_list();
  68.    cout << "main: trying to display initial size of ll1 - " << ll1.list_length() << endl;
  69.    ll1.push_front("aaaaa");
  70.    ll1.push_back("bbbbb");
  71.    ll1.push_front("before aaaaa");
  72.    ll1.push_back("after bbbbb");
  73.    cout << "main: length of ll1 after 4 pushes - " << ll1.list_length() << endl;
  74.    cout << "main: now trying to display ll1 after 4 push's" << endl;
  75.    ll1.display_list();
  76.    cout << "main: displaying final size of ll1 - " << ll1.list_length() << endl;
  77.    ll1.destroy_list();
  78.    cout << "main: displaying size of list 1 after destroy - " << ll1.list_length() << endl;
  79.    cout << endl;
  80.  
  81.    LL ll2;
  82.  
  83.    ll2.push_front("33333");
  84.    ll2.push_front("22222");
  85.    ll2.push_front("11111");
  86.    ll2.push_back("44444");
  87.    ll2.push_back("55555");
  88.    ll2.push_back("66666");
  89.    cout << "main: now trying to display ll2 after 6 push's" << endl;
  90.    ll2.display_list();
  91.    cout << "main: now searching for node 44444" << endl;
  92.    if (ll2.search_list("44444"))
  93.    {
  94.        cout <<"main: found node 44444" << endl;
  95.    }
  96.    else
  97.    {
  98.        cout << "main: did not find node 44444" << endl;
  99.    }
  100.    cout << "main: now searching for node 44445" << endl;
  101.    if (ll2.search_list("44445"))
  102.    {
  103.        cout <<"main: found node 44445" << endl;
  104.    }
  105.    else
  106.    {
  107.        cout << "main: did not find node 44445" << endl;
  108.    }
  109.    cout << "main: now trying to delete node 44444" << endl;
  110.    if (ll2.delete_node("44444"))
  111.    {
  112.        cout <<"main: node 44444 deleted" << endl;
  113.    }
  114.    else
  115.    {
  116.        cout << "main: did not find 44444 for delete" << endl;
  117.    }
  118.    if (ll2.search_list("44444"))
  119.    {
  120.        cout <<"main: searched for 44444 after delete, found" << endl;
  121.    }
  122.    else
  123.    {
  124.        cout << "main: searched for 44444 after delete, not found" << endl;
  125.    }
  126.    cout << "main: displaying whole list after delete 44444" << endl;
  127.    ll2.display_list();
  128.    cout << "main: now trying to delete node 11111" << endl;
  129.    if (ll2.delete_node("11111"))
  130.    {
  131.        cout <<"main: node 11111 deleted" << endl;
  132.    }
  133.    else
  134.    {
  135.        cout << "main: did not find node 11111 for delete" << endl;
  136.    }
  137.    cout << "main displaying whole list after delete 11111" << endl;
  138.    ll2.display_list();
  139.    ll2.destroy_list();
  140.  
  141.    return 0;
  142. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top