From 330af1a823d91d6055597cd3d81c679611e8d09e Mon Sep 17 00:00:00 2001 From: sherlock Date: Mon, 17 Mar 2025 13:43:17 +0530 Subject: [PATCH] Fixed OS/C/Week5/q2opt fixed --- OS/C/Week5/q2 | Bin 0 -> 34048 bytes OS/C/Week5/q2_opt | Bin 0 -> 34056 bytes OS/C/Week5/q2_opt.c | 2 +- OS/C/Week5/q2opt | Bin 33768 -> 33656 bytes OS/C/Week5/q2opt.c | 13 ++++++++++++- 5 files changed, 13 insertions(+), 2 deletions(-) create mode 100755 OS/C/Week5/q2 create mode 100755 OS/C/Week5/q2_opt diff --git a/OS/C/Week5/q2 b/OS/C/Week5/q2 new file mode 100755 index 0000000000000000000000000000000000000000..2ed273f9747ed25f37f750a3f9150d0841c5cec6 GIT binary patch literal 34048 zcmeI5e{5S<702(3oz_iK;xui;+O>TJb!)4VqJm&*6Xqnfk}hkU*=Cq+^wqUr5-a|Z z*e|T1qjei9It@WxbubA*|3E-oZBsNTC`@z_t;Pn3DHY?#m{2x}%^5-!|4jANHhj;0 z&+hYEVMzRg#5vN*J?Gr>?mPE$@5_Jp`jz+oezQpkML_DHEl|}h#7UvT65fGSaUdZ~9)dzKAsl`OYz{F4@pJJO$OXy8;P(5=0NKc4Q3X!M!Xq8oTe8Te8<3fBKVPf-PXaqjx&7BZp1})Vx z2(=64l77e@bl4F*PqjORo>8H+FLqAkvOANBLp$S>$vAwH^-!wggm0IB^I!Mu_(|i@ zP0yEFEjXwxJ9<NfC(@GCcp%k025#WOn?b60Vco%m;e)C0!)AjFaajO1egF5U;<2l2`~XB zzyz286JP>NfC(@GCcp%k025#W{|5w?F1hEgXIhFkj;t!)m~t0z4sFJ>!dLbvzVh_c z#%oIC->hei7%%S%QT;lvfo3H#%AU|7lDf5f#MS1Jw_G=~TTW`g`r_8H}Eh5J=nYiXr#6L=H=hkgi z%<(8bjht%V@^kC@tUg)qN?%!^UcCGC=0EN!{1#)YA|JejRz8dO3L2N@*5WJIA@_Jw zK6nxRh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_JdXB;-}RjJE=$YCFG*bh1EuRH8- zJM70Dwuws!x+j9}h@kr+=xzwQ7lQ7Dp!*H*ah^*{(lwy&ib_)OSDfqqzfaxd(S1`_L2bH-5PErKHu@++0XQB4Zr=hT|fEOY4R^h9_vd~Z_CH!W{fjm4m;b*V r|3mMskDqDoXga!~@B9~hFYY?I*t7R^*XF|y%^bS#t #include -void main () { +int main () { // array declaration char *strings[5]; diff --git a/OS/C/Week5/q2opt b/OS/C/Week5/q2opt index f2352aa8eeca78ffdf503604bd5d6444c9f12ed7..5d2db884b608bb444a0465dd492f965f2232f7ba 100755 GIT binary patch delta 1470 zcma)6UrbwN6hGg+EiH7cl;PMQj$$JgmJq?2AwqjeiH>OuGL5{*U4^oCjDMw$Aue22 zx1laen@iNa2nz|J)0ib&vNqGPg&60b7~}z2G!gb-N<@vuht{p)@4Ic2X=dU{&OP@# z-#O=Z&bjB@_-P?=N(e1lHX4W+5w#0=fHuNw&cbGAT8TT2nw@Gbb6Av&x+0@i)N%F$ zv#V~Ql2Pkq!d7g6rz2QJp2yuD$Yj8iE*MJ4BPI(WVG& z!`DT5dDF$2w@I-|7#Ue^PyEVM$wW@tdES+=aiwi81UsUY zEU)Juwz{-!+$<#{uJ@xf;!C98VXG$#yX8xCAwl$gF#g$8iC5tEV^oxNFmeYIs@DRf zos4i=$N2&R+DEEzFD29Gj_7^_wcn~r@Z_}ukQ^$s%puw3&CTL$QJM}#-h>VxAw=W| zV}>T}q_oAy%oO8>0F6a>i!znRS*C4h)w)@U@#NM;3fmbawIB_Sa5aKteK`o)8T&;8 zQQFFJhv8e=tx14B>j*!T1vOKS0bpBdv^j$L(B=g5 zcCkRfED2@m2aXz>%j-MRWj)aE4|uxj^XTEBJj!cz`#pUD>x+Funp&N4mT%?jD4|Nu z*t#X>3zwdft~oKU)_f~;tza)$uUeGmv8`Cs5^xo`9$HSa=a?@*a(BPKhvWgjuP@L| z@=(Cv**ie;up4)2Vlwe>qAjLK8zb1b>DRD#a<3O5Je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J1jM{zAEqs_!2x^KWDxqldI#=TgBgArjDwJd^z z-*6Lboj5#*oKpW-L=p!jFRB1P>*kBqOkQ*QT_!m{?p*C({narSe*`(j6#<<^(ehNqV{iZ9)7TTLBq`j885oj6d@ z_Sv)UzPuB+$MR=`v%`xQzR?ta!O`;TaLp&HH*U}Q S4<--Q{#thP4bR8vZT$mqh{@Xk diff --git a/OS/C/Week5/q2opt.c b/OS/C/Week5/q2opt.c index 4ad4a11..88104f1 100644 --- a/OS/C/Week5/q2opt.c +++ b/OS/C/Week5/q2opt.c @@ -12,7 +12,18 @@ int compare_strings(const void *a, const void *b) { int main(int argc, char *argv[]) { pid_t pid = fork(); if (pid == 0) { - qsort(&argv[1], argc - 1, sizeof(char *), compare_strings); + int i, j; + int count = argc - 1; + char **strings = &argv[1]; + for (i = 0; i < count - 1; i++) { + for (j = 0; j < count - i - 1; j++) { + if (strcmp(strings[j], strings[j + 1]) > 0) { + char *temp = strings[j]; + strings[j] = strings[j + 1]; + strings[j + 1] = temp; + } + } + } printf("Child Sorted:\n"); for (int i = 1; i < argc; ++i) printf("%s\n", argv[i]);