From e3b8d32540221a63a3a858478db89ef93463fb4e Mon Sep 17 00:00:00 2001 From: erlanggabagja <59926522+erlanggabagja@users.noreply.github.com> Date: Sat, 8 Feb 2020 21:48:57 +0700 Subject: [PATCH 1/4] Update list.cpp --- list.cpp | 61 +++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 47 insertions(+), 14 deletions(-) diff --git a/list.cpp b/list.cpp index f61d73d..9672bac 100644 --- a/list.cpp +++ b/list.cpp @@ -6,8 +6,8 @@ void createList(List &L) { */ //-------------your code here------------- cout<<"your code here"< Date: Sat, 8 Feb 2020 21:51:56 +0700 Subject: [PATCH 2/4] Update list.h --- list.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/list.h b/list.h index d021225..5e8af3b 100644 --- a/list.h +++ b/list.h @@ -30,14 +30,14 @@ typedef struct elmlist *address; struct elmlist{ //------------- your code here ----------- - - + infotype info; + address next; //---------------------------------------- }; struct List{ //------------- your code here ----------- - + address first; //---------------------------------------- }; From faf25da8b186c77b3079da4d17d685f0a6811d37 Mon Sep 17 00:00:00 2001 From: erlanggabagja <59926522+erlanggabagja@users.noreply.github.com> Date: Sat, 8 Feb 2020 21:54:09 +0700 Subject: [PATCH 3/4] Update operation.cpp --- operation.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/operation.cpp b/operation.cpp index 0a0e067..3bfd551 100644 --- a/operation.cpp +++ b/operation.cpp @@ -14,7 +14,22 @@ void insert_sorted(List &L, infotype x) { //-------------your code here------------- cout<<"your code here"< info(next(Q)))){ + Q = next(Q); + if (next(Q) == NULL){ + P = allocate(x); + insertLast(L,P); + }else if (info(P)!=info(Q)){ + P = allocate(x); + insertAfter(L,Q,P); + } + } + } //---------------------------------------- } From 2c317a6846ee70c1b339e54f31c96e5006ed36ae Mon Sep 17 00:00:00 2001 From: erlanggabagja <59926522+erlanggabagja@users.noreply.github.com> Date: Sat, 8 Feb 2020 21:56:36 +0700 Subject: [PATCH 4/4] Update Main.cpp --- Main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Main.cpp b/Main.cpp index 297d6ca..fb46dea 100644 --- a/Main.cpp +++ b/Main.cpp @@ -34,7 +34,7 @@ int main() { //================================================== // TEST INSERT AFTER P = findElm(L, 6); - insertLast(L, allocate(5)); + insertLast(L, P, allocate(5)); printInfo(L); cout<<"output should be: 8, 3, 6, 5, 4, 2,"<