Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.01 KB | None | 0 0
  1. #include <iostream>
  2. #include "sortedtype.h"
  3.  
  4. using namespace std;
  5.  
  6. void printList (SortedType<int>* list) {
  7.     int item;
  8.     for (int i = 0; i < list->LengthIs(); i++) {
  9.         list->GetNextItem(item);
  10.         cout << item << " ";
  11.     }
  12.    
  13.     list->ResetList();
  14.     cout << endl;
  15. }
  16.  
  17. int main () {
  18.     SortedType<int> list;
  19.  
  20.     cout << list.LengthIs() << endl;
  21.  
  22.     int input;
  23.     for (int i = 0; i < 5; i++) {
  24.         cin >> input;
  25.         list.InsertItem(input);
  26.     }
  27.  
  28.     printList(&list);
  29.  
  30.     int item;
  31.     bool found;
  32.     list.RetrieveItem(item = 6, found);
  33.     if (found)
  34.         cout << "Item is found" << endl;
  35.     else
  36.         cout << "Item is not found" << endl;
  37.  
  38.     list.RetrieveItem(item = 5, found);
  39.     if (found)
  40.         cout << "Item is found" << endl;
  41.     else
  42.         cout << "Item is not found" << endl;
  43.  
  44.     if (list.IsFull())
  45.         cout << "List is full" << endl;
  46.     else
  47.         cout << "List is not full" << endl;
  48.  
  49.     list.DeleteItem(1);
  50.  
  51.     printList(&list);
  52.  
  53.     if (list.IsFull())
  54.         cout << "List is full" << endl;
  55.     else
  56.         cout << "List is not full" << endl;
  57.  
  58.     return 0;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement