vault backup: 2024-11-19 21:54:36
This commit is contained in:
parent
b677e73bbe
commit
9225582340
@ -63,7 +63,22 @@ while (p != NULL) {
|
||||
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;
|
||||
}
|
||||
prev->next = new_node;
|
||||
new_node->next = cur;
|
||||
return list;
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
```c
|
||||
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;
|
||||
}
|
||||
prev->next = new_node;
|
||||
new_node->next = cur;
|
||||
|
Loading…
Reference in New Issue
Block a user