vault backup: 2024-11-19 22:10:22
This commit is contained in:
parent
56b77cc8ff
commit
1911f9cfef
@ -77,11 +77,11 @@ In the above code, if the new item needs to be inserted at the *end* of the list
|
||||
struct node *insert_into_ordered_list(struct node *list, struct node *new_node) {
|
||||
struct node *cur = list, *prev = NULL;
|
||||
while (cur->value <= new_node->value) {
|
||||
prev = cur;
|
||||
cur = cur->next;
|
||||
if (cur->next == NULL) {
|
||||
break;
|
||||
}
|
||||
prev = cur;
|
||||
cur = cur->next;
|
||||
}
|
||||
prev->next = new_node;
|
||||
new_node->next = cur;
|
||||
|
Loading…
Reference in New Issue
Block a user