Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void DelEnd(node*& H)
- {
- if (H != NULL)
- {
- node* P = H;
- if (P->next == NULL)
- DelNode(H);
- else
- {
- while (P->next->next != NULL)
- P = P->next;
- DelNode(P->next);
- }
- }
- }
- // Usuń co drugi
- void Del2nd(node*& H)
- {
- node* P = H;
- while (P && P->next)
- {
- DelNode(P->next);
- P = P->next;
- }
- }
- // Kopiuj parzyste elementy
- void CopyEven(node* H)
- {
- if (H != NULL)
- {
- node* P = H;
- while (P != NULL)
- {
- if (P->val % 2 == 0)
- {
- node* q = new node;
- q->val = P->val;
- q->next = P->next;
- P->next = q;
- P = q->next;
- }
- else
- {
- P = P->next;
- }
- }
- }
- }
- //12 Zamiana X z nastepnikiem
- void ReplaceXandNext(node*& H, int x)
- {
- node* P = H;
- if (H->val != x)
- {
- while (P->next != 0 && P->next->val != x)
- {
- P = P->next;
- }
- if (P->next != NULL && P->next->next != NULL)
- {
- node* q = P->next;
- P->next = q->next;
- q->next = P->next->next;
- P->next->next = q;
- }
- }
- else
- {
- H = H->next;
- P->next = H->next;
- H->next = P;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement