bool Cycle(Node **head) {
Node *pCurr = *head;
Node *pCurNex = *head;
if( *head == NULL ) {
return false;
}
do {
pCurr=pCurr->next;
pCurNex= pCurNex->next->next;
}while((pCurr != pCurNex) && pCurr != NULL && pCurNex != NULL && pCurNex->next!= NULL);
if(pCurr == NULL || pCurNex ==NULL || pCurNex->next == NULL)
return false;
else
return true;
}
No comments:
Post a Comment