Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void pomnoz_liste_y_razy(node *&H, int y)
- {
- if(H == NULL)
- return;
- if(y<2)
- return;
- node * tmphead = H;
- node * tmp = H;
- node * koniec;
- while(tmp != NULL)
- {
- tmp = tmp -> next; // PRZEJEZDZAMY TMP NA KONIEC LISTY
- }
- koniec = tmp; // PRZESUWAMY WSKAZNIK KONIEC NA KONIEC LISTY
- // MNOZYMY LISTE PRZEZ 1 TO JEJ NIE MNOZYMY
- for (int i =1; i<y ; i++) // I JEST ROWNE JEDEN BO DLA Y RONWEGO 1 PETLA SIE NIE WYKONA
- {
- cout << " 3";
- while(tmphead != koniec -> next) // PETLA WYKONUJE SIE TAK DLUGO AZ KONIEC LISTY BEDZIE NULLEM
- {
- node * p = new node; // TWORZYMY NOWEGO NODE
- p -> val = tmphead -> val; // NADAJEMY MU WARTOSC TMPHEAD
- tmp -> next = p; // TMPHEAD PRZESUWAMY W STAREJ CZESCI LISTY O JEDEN DO PRZODU
- tmphead = tmphead -> next;
- tmp = tmp -> next;
- }
- koniec = tmp;
- tmp -> next = NULL;
- cout << " 4";
- }
- cout << " 5";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement