Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- element* insert_sorted(element *first, element *new_elem) {
- if (first==NULL){
- first = new_elem;
- return first;
- }
- if (first!=NULL && ((first->isbn) > (new_elem->isbn))){
- new_elem->next = first;
- first = new_elem;
- return first;
- }
- element *tmp= first;
- element *tmp2= tmp->next;
- if (tmp2 ==NULL) {
- tmp->next = new_elem;
- return first;
- }
- while ((tmp2 != NULL) && ((tmp->isbn) < (tmp2->isbn))){
- tmp2 = tmp2->next;
- tmp = tmp2;
- }
- new_elem->next = tmp2;
- tmp = new_elem;
- return first;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement