void testdetectloop() { struct node* node = buildlistattailbyref(3); printlist(node, "node"); node->next->next = node; printf("\nloop exists = %s\n", detectloop(node) ? "true" : "false"); }
int main() { Node* head = NULL; push(&head, 20); push(&head, 4); push(&head, 15); push(&head, 10); head->next->next->next->next = head; detectloop(head); return 0; }