寫正確函數須要注意的地方:鏈表的合併排序

Node* mergeSort(Node* head, int length) { if(length==0) return NULL; if(length==1) { head->pNext=NULL;//必定要賦值爲NULL,不然可能出現死循環。 return head; } int halflength=length/2; Node* halfp=head; fo
相關文章
相關標籤/搜索