int main(void) { SinglyLinkedList<int> *list = new SinglyLinkedList<int>(); for(unsigned int i = 0; i < 5; i++) { list->push(i); } list->append(-1); list->append(-2); list->printList(); list->deleteNode(-1); list->printList(); list->deleteNode(4); list->printList(); list->deleteNode(-2); list->printList(); delete list; }
int main(int argc, const char * argv[]) { Node *head; SinglyLinkedList *s = new SinglyLinkedList(); int size = 15; //create for (int i=0; i<size; i++) { s->add(head, i+1); } //Print Nodes' value s->printList(head); //Print middle node index Node* mid = s->rFindMid(head, head); cout<<"Middle node is:"<<mid->val<<endl; return 0; }