#include #include "ListElem.h" #include "pj3.h" void Print(ListElem *head) { ListElem *p; p = head; cout << "List ==> "; while ( p != NULL ) { cout << p->value << " "; p = p->next; } cout << "\n\n"; } int main(int argc, char *argv[]) { ListElem *head, *p; head = NULL; Print(head); cout << "Testing insert into empty list:" << endl; p = new ListElem; p->value = 1500; InsertOrdered(head, p); Print(head); cout << "Testing insert into end of list:" << endl; p = new ListElem; p->value = 2500; InsertOrdered(head, p); Print(head); cout << "Testing insert at head of list:" << endl; p = new ListElem; p->value = 1000; InsertOrdered(head, p); Print(head); cout << "Testing insert at middle of list:" << endl; p = new ListElem; p->value = 2000; InsertOrdered(head, p); Print(head); // ---- delete cout << "Testing delete non-existing element:" << endl; DeleteOrdered(head, 9999); // Delete element with value = 9999 Print(head); cout << "Testing delete element at head:" << endl; DeleteOrdered(head, 1000); // Delete element with value = 1000 Print(head); cout << "Testing delete a general element:" << endl; DeleteOrdered(head, 2500); // Delete element with value = 2500 Print(head); cout << "Testing delete a general element:" << endl; DeleteOrdered(head, 2000); // Delete element with value = 2000 Print(head); cout << "Testing delete a general element:" << endl; DeleteOrdered(head, 1500); // Delete element with value = 1500 Print(head); cout << "Testing delete empty list:" << endl; DeleteOrdered(head, 1500); // Delete element with value = 1500 Print(head); }