vault backup: 2024-11-19 21:54:36

This commit is contained in:
zleyyij 2024-11-19 21:54:36 -07:00
parent b677e73bbe
commit 9225582340

View File

@ -63,7 +63,22 @@ while (p != NULL) {
struct node *insert_into_ordered_list(struct node *list, struct node *new_node) { struct node *insert_into_ordered_list(struct node *list, struct node *new_node) {
struct node *cur = list, *prev = NULL; struct node *cur = list, *prev = NULL;
while (cur->value <= new_node->value) { 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; prev->next = new_node;
new_node->next = cur; new_node->next = cur;