From cdb08a328eef34efe5b8217926ec7b4301e6ddab Mon Sep 17 00:00:00 2001 From: Sambo Chea Date: Sat, 1 Aug 2020 21:13:49 +0700 Subject: [PATCH] Clean and call the function with menu --- tests/linkedlist | Bin 16712 -> 17152 bytes tests/linkedlist.c | 44 ++++++++++++++++++++++++++++++++++++-------- 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/tests/linkedlist b/tests/linkedlist index b19ee0aab373bb59978000ad6f7599f167858fd9..84c9e2a9be1551f4de9e2c3a08bc88c28e051763 100755 GIT binary patch literal 17152 zcmeHOZE##w89uw)rJ*02q_j2iVQ&l7pmv)=OIs>%H)+}prVvUhWw6|CvNy@NrjE>+BQ>;>D9F59=Uko3^$A%VM1T;utecp4(#6n?; zkBE!JIY8#&Z%PeO#W5Z6D+SXgZ5IF~zhhc|%x^*>*(4%X%WZ{n3yG3nrI?ykbT+6& zrlLj3+OPbW8qiTOqEq>jNQbKooHz&|+$e&rna0pJGywdHaE_1Z(ZtA{U~0~g5tAaWnRLfHEg zjB0G&K=x4&PUF2%8X0J0ppk(_1{xV?WT26OMh5=BGw^2fNB$L^INcPT49={@?czPh z9e;T`I`Q+S6EZR74KDyLuYM8R<`pJ5l1E54^IREa^`A+mTiuyyDgT~iKgq|X`~=B# zYdiChlz&Dt-O|n+mGVzWrs>tp5h*`RGTl_JTiz*l6l%E@7hdn2#mz4lNCH=1GU9ZakkG&s2fM}rKB`!wX%f#IT?#P}KI;%$E&eKygA1qqHqlNC-=w$coip>BvPBXnlRg|<()1n7-G6mkR;8jp!NVToxfp#G&E~dbfr08@N0qPcY zyiP-=>)8L{-Ez6A9Z!5hb$Zd%HUur+5B;g#Xy3!YQ5VMcWbgs9Q57J6!Ecg?0ecf{ zQ3a*yZn6#@z;>dDy?7^y-Dl9!y>3fy_SS45Odo|ozM56dmqI`DLyV8f;ME*w1DQ+) zKPrjJ?ncPVAyeB8H0Ftap)n_e|NJ-&T^yuG+=`!r=G3h)eHOYX?YgBhV+FK) zj?6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M{!o zP$$<_=JI0)S%3fDk=;Z62ge2vjP>su92td=<*v<)+52)v4`Y6@LB4v#OSW2}-$@#l zb5WBV=nHfBwGj@OaUd5Wf zt_*7xkz|HSBHzSeT}@4W4wq1pSa*q^${>d01H`Dxh@QuR zsbpcqVvw&{+qDjzc9JPo?msTQSVqO6;y8&TjkXr#Pi38DLJl?}qTT9U`W zt49Jk*|1Q`6p3>8nwYSQ)#%0>>(}aKA{GGoKR7SrtpbOrwrxzued_U5!G` zrZdtJ6)tYlQq-kHP8J(D!*Hrt+OToivNAS~xXQw;PT&GY&(Y1Ho?f&DFs={9{?-S_ zDLWAN<0|UIf73>qFHu(hi|-(G6MK(TjjbTlbWOXb9*7(_eAvE=4D^{0Qu3|%Kk4>;WH)O^m@$KI$; zzQo^#XnO=El77YM66f#N4Rc9dDXNCGx~N)=mCi3E$2pxjrF)%Pse^N=X0MaZ1pJ&z mVn0=NC4B>Qk0A|sV0TxOx7cK>3e0sidlwV7_5haJB7Xx0r=sHk diff --git a/tests/linkedlist.c b/tests/linkedlist.c index 5b3ac24..b978a30 100644 --- a/tests/linkedlist.c +++ b/tests/linkedlist.c @@ -24,27 +24,55 @@ int main(void) while (1) { - if (count == 100) - { - exit(EXIT_SUCCESS); - } - + printf("\n"); + // show menu display_menu(); - } - printf("\nGoodbye!"); + printf("Enter your option: "); + scanf("%d", &selected); + + if (selected == 1) + { + printf("Enter you element to add first: "); + scanf("%d", &data); + add_first(data); + } + else if (selected == 2) + { + printf("Enter you element to add last: "); + scanf("%d", &data); + add_last(data); + } + else if (selected == 3) + { + traverse(); + } + else if (selected == 4) + { + remove_first; + } + else if (selected == 5) + { + remove_last(); + } + else + { + printf("\nGoodbye!"); + exit(EXIT_SUCCESS); + } + } return 0; } void display_menu() { - printf("1. Add first element\n"); printf("2. Add last element\n"); printf("3. Traverse element\n"); printf("4. Remove first element\n"); printf("5. Remove last element\n"); + printf("Any to quite program\n"); } void add_first(int element)