Advertisement
Guest User

Untitled

a guest
Oct 24th, 2013
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.85 KB | None | 0 0
  1. Node* sort_list(Node* head)
  2. {
  3.        Node* tempNode = NULL;
  4.                 Node* tempHead = head;
  5.                 Node* tempNext = head->next;
  6.                 while(tempNext!=NULL){
  7.                         if(tempHead->key > tempNext->key){
  8.                                tempNode = tempHead;
  9.                                tempHead = tempNext;
  10.                                 tempNode->next = tempNode->next->next;
  11.                                 tempHead->next = tempNode;
  12.                                 tempNext = tempHead->next;
  13.                                 print_list(tempHead);
  14.  
  15.  
  16.                         }
  17.                         else{  
  18.                                 tempHead = tempHead->next;
  19.                                 tempNext = tempNext->next;
  20.  
  21.                         }
  22.                 }
  23.  
  24.        
  25.         return head;
  26.  
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement