From b9356d3bc31ab694ddb4896ce41bb4912f237a4f Mon Sep 17 00:00:00 2001 From: Sambo Chea Date: Sat, 1 Aug 2020 21:59:39 +0700 Subject: [PATCH] Updated the add last element inti linkedlist --- tests/linkedlist | Bin 17152 -> 17152 bytes tests/linkedlist.c | 9 ++++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/linkedlist b/tests/linkedlist index 84c9e2a9be1551f4de9e2c3a08bc88c28e051763..99716cf8209ac5bf7feb6e354e3435b0fc4f4f7d 100755 GIT binary patch delta 1004 zcmY*YT}YEr82--eQ@=2se-q80{RpC_TjCsDm>VhENJz-_gCH3ytjsLug%{yMvwaN7 zJP8&B-Q`U`JrU{A!K^ID11bSgiG_^D`U7VgX$?U-Sp7Xx%^FGh}{ds$dx0gJN zCDLHD5LtsXkr<`TsGVq&I!Q2bPPY@y>8z2%oRY435HEQ(R>3hjrq(Dy^$S7*v?EDR z`jw%iR6BTVVrw7$8U|rKx+s)cqmVX%;3Uv4fCJpY_Sp7 z?huj1Iv!SqF^Z3m(iORR%U)|Obc(qStP^&uV^Cjw4ys?w{412qDSmNZ1TX;D7Q`C` zJHsvG9KxATGrWaqCdFxld<92#AHrJ+rKNgs-_YJv`-yUdd&>0)r^cI$6LNYYoz4C0 z3E5k=)75?D@ACw~cFHNw*j!HehppBohh2`oqSr{Dtj_<9cNH57D%qNM(ts9ET9;nf z(AcPTw|XvXo84F2J;s)Xc8_kqQ0;EL*wm>6Vmz|3!qr4T{54J-vZzcW?~{0Q^_kFPU!2WZ-0Yy|j_X6Xy_ zO;9tUTd0gts{tnLYUD(o!^*|3#P-oE`aIQ_6?#vfq58Z^U+S}oK&SONIv4yS->xlQ z-K#owAX=rw#l&JBbcL|L(o{nZaZxj_PpQjbAZ@hMU?)S$n1M+&R8&KJ%8}wnQN%~* z4;#rGO)NyZLaHy3$7UMCeOb;-M>1Uzx~*Khf{>PSvN=lS|2!Rzu=8xdY#AX_rPEPOHYT1EvpYy)YbKmFL?!8@p)a6IR zGQ@dPnE3MIOl0DwrHN`9*Pw7_NSCNWI$Qh@67nSX(>Yg;jo~L=MO8vLV-%r2?9I}n zcHwT83L!Oqmc2tBIlu=UQ9j^Ui^y@OG8apgc}07>4qEw{MN{ z%EKF48zb(F5fX6)*-9V-Z^OA@8=}Udni2+>xfZ0v!6YG#VV|;~^Izlr1|k0$O%;RD zwU=OV8151u0Uv3B0MDTh!yGXt0PCZr zBL-1iG)iYYWb0OIEzGH-bHG}Wur30A{sl;bY}MaEfI4e};yyp5-wEfx*b*-oU zT-zD#dC%nzt>?0~?ZU;5tAAb-23vJcTiuI<41}jahrSrK;7j^!RR_#wVFq0Vu&ZGY<3W94 zemb~hgPO6YXZR(Dw$Zm+4Vxxmqxg$H9~tqcUZe9x2^oN9QYg74Pn9LaBD9xrr9p#^ z;}dWl#Xf@pUBM3xPWA!BV}&JFk%sFeN-UPtA-Ax<^obO?@!Vb$3gOJM?Z_w;m8~N5 z4(rT)&>As2kqiGahe0$}ZbGSezFdO_FjsM15>?^;iW$UVkHv}lgb|A=6}`c8RVL02 i-x*zQoM&~yl+#udm;4m*pw+?|^)@PCjKU{tq4YPclw8mN diff --git a/tests/linkedlist.c b/tests/linkedlist.c index b978a30..63e9c84 100644 --- a/tests/linkedlist.c +++ b/tests/linkedlist.c @@ -25,7 +25,7 @@ int main(void) while (1) { printf("\n"); - + // show menu display_menu(); @@ -122,11 +122,13 @@ void add_last(int element) { head = node; head->next = NULL; + + printf("Element %d has been add into first/last!\n", element); return; } // store current as tempo - temp = node; + temp = head; while (temp->next != NULL) { @@ -134,7 +136,8 @@ void add_last(int element) } temp->next = node; - node->next = NULL; + node->next = NULL; + head = temp; } void traverse()