Advertisement
Guest User

Untitled

a guest
Jun 18th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. void Przerob(struct tnode** head){
  2.  
  3. if(!*head){
  4. printf("Lista jest pusta!");
  5. return;
  6. }
  7.  
  8. struct tnode* curElement = *head;
  9. struct tnode* nextElement = (*head)->next;
  10.  
  11. while(nextElement != NULL){
  12. if(nextElement->value < 0){
  13. curElement->next = nextElement->next;
  14. free(nextElement);
  15. nextElement = curElement->next;
  16. } else {
  17. curElement = curElement->next;
  18. nextElement = curElement->next;
  19. }
  20.  
  21. }
  22.  
  23. if((*head)->value < 0){
  24. curElement = (*head)->next;
  25. free(*head);
  26. *head = curElement;
  27. }
  28.  
  29. curElement->next = *head;
  30.  
  31. printf("\n");
  32.  
  33. curElement = *head;
  34. do{
  35. printf("%d ",curElement->value);
  36. curElement = curElement->next;
  37. }while(curElement != *head);
  38.  
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement