Advertisement
Guest User

Untitled

a guest
Apr 26th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. void pomnoz_liste_y_razy(node *&H, int y)
  2. {
  3. if(H == NULL)
  4. return;
  5. if(y<2)
  6. return;
  7.  
  8. node * tmphead = H;
  9. node * tmp = H;
  10. node * koniec;
  11.  
  12. while(tmp != NULL)
  13. {
  14. tmp = tmp -> next; // PRZEJEZDZAMY TMP NA KONIEC LISTY
  15. }
  16. koniec = tmp; // PRZESUWAMY WSKAZNIK KONIEC NA KONIEC LISTY
  17. // MNOZYMY LISTE PRZEZ 1 TO JEJ NIE MNOZYMY
  18. for (int i =1; i<y ; i++) // I JEST ROWNE JEDEN BO DLA Y RONWEGO 1 PETLA SIE NIE WYKONA
  19. {
  20. cout << " 3";
  21. while(tmphead != koniec -> next) // PETLA WYKONUJE SIE TAK DLUGO AZ KONIEC LISTY BEDZIE NULLEM
  22. {
  23. node * p = new node; // TWORZYMY NOWEGO NODE
  24. p -> val = tmphead -> val; // NADAJEMY MU WARTOSC TMPHEAD
  25. tmp -> next = p; // TMPHEAD PRZESUWAMY W STAREJ CZESCI LISTY O JEDEN DO PRZODU
  26. tmphead = tmphead -> next;
  27. tmp = tmp -> next;
  28. }
  29. koniec = tmp;
  30. tmp -> next = NULL;
  31. cout << " 4";
  32. }
  33. cout << " 5";
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement