1:struct LLNode *merge(struct LLNode *list1, 2: struct LLNode *list2){ 3: struct LLNode *head =initLLNode('\0'); 4: struct LLNode *tail=head; 5: if (list1==NULL)return(list2); 6: if (list2==NULL)return(list1); 7: while (list1 && list2){ 8: if ((list1->c) <= (list2->c)){ 9: tail->next = list1; 10: list1 = list1->next; 11: } else{ 12: tail->next = list2; 13: list2 = list2->next; 14: } 15: tail = tail->next; 16: } 17: if (list1)tail->next = list1; 18: else tail->next = list2; 19: return(head->next); 20:} |