Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- List Cut(List L, Position P)
- {
- if (!L || !P) {
- return NULL;
- }
- List root = MakeEmpty(NULL);
- root->Element = L->Element;
- List leaf = root;
- List new_leaf = NULL;
- List pos = L->Next;
- while(pos != P && pos != NULL) {
- new_leaf = MakeEmpty(NULL);
- new_leaf->Element = pos->Element;
- leaf->Next = new_leaf;
- leaf = new_leaf;
- pos = pos->Next;
- }
- return root;
- }
Add Comment
Please, Sign In to add comment