From 1052d5c781b38b43ee55f09f0f0115a918290502 Mon Sep 17 00:00:00 2001 From: reyhanfarrafi <59947048+reyhanfarrafi@users.noreply.github.com> Date: Sat, 8 Feb 2020 23:38:19 +0700 Subject: [PATCH] Inserted the requested code Reyhan Fadhlurohman Arrafi 1301190356 --- Main.cpp | 2 +- list.cpp | 78 +++++++++++++++++++++++++++++---------------------- list.h | 6 ++-- operation.cpp | 14 +++++++-- 4 files changed, 59 insertions(+), 41 deletions(-) diff --git a/Main.cpp b/Main.cpp index 297d6ca..f3dfaf8 100644 --- a/Main.cpp +++ b/Main.cpp @@ -34,7 +34,7 @@ int main() { //================================================== // TEST INSERT AFTER P = findElm(L, 6); - insertLast(L, allocate(5)); + insertAfter(L, P, allocate(5)); printInfo(L); cout<<"output should be: 8, 3, 6, 5, 4, 2,"< x) { + insertFirst(L, allocate(x)); + } else if (findElm(L, x) == NULL) { + while (P != NULL && info(P) < x) { + Q = P; + P = next(P); + } + insertAfter(L, Q, allocate(x)); + } //---------------------------------------- }