Skip to content
Snippets Groups Projects
Commit e726137c authored by Isak Hall's avatar Isak Hall
Browse files

lab0 third comp done

parent 6e7e2826
No related branches found
No related tags found
No related merge requests found
No preview for this file type
......@@ -64,7 +64,7 @@ void input_sorted(struct list_item *first, int x){
while(current != NULL){
//if we find something larger than x, we insert x before current, and after prev.
if (current->value > x){
prev->next = newItem;
newItem->next = current;
......@@ -74,6 +74,11 @@ void input_sorted(struct list_item *first, int x){
prev = current;
current = current->next;
}
if (current == NULL){
prev->next = newItem;
newItem->next = NULL;
}
}
void clear(struct list_item *first){
......
......@@ -11,7 +11,9 @@ int main(){
prepend(&root, 2);
append(&root, 6);
input_sorted(&root, -2);
input_sorted(&root, -1);
input_sorted(&root, 5);
input_sorted(&root, 21);
input_sorted(&root, 22);
print(&root);
clear(&root);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment