From f0d910c22f80d7cca06cab171adb18bde8f9ce4e Mon Sep 17 00:00:00 2001 From: Yaroslav Orlianskyi Date: Wed, 30 Mar 2022 23:36:37 +0200 Subject: [PATCH] SAD --- du4/program | Bin 5815 -> 6010 bytes du4/program.c | 97 ++++++++++++++++++++++++++------------------------ du4/test | Bin 5764 -> 5184 bytes du4/test.c | 64 +++++++-------------------------- 4 files changed, 62 insertions(+), 99 deletions(-) diff --git a/du4/program b/du4/program index 5f7e82c164886a1d964b22fa0951b603b05711f6..dce0973ec5ce04b08f0ad4ff5be97f3b715cd92b 100755 GIT binary patch literal 6010 zcmb7IeQcA*89yfuHEnQ0fQ>>_tYO*!i3v1NRzSn#gRcN71j<^<8z**R7srn5*EBGu zhBNu+2)-I!RlN{Ce&e;^I9Z0puQC=vaOqH2OM2Gu}I2328v?xT3W-<>bK=0mWP z9^XCp{GR8Yd+xb=&-ZR+b(PI#6S`!HY(ef&((Wij{n2wuQYKu&A&SH#Q7A^Bi?Xsd zU_epmVat15cuyV~~~rzXW5GD!`Mptmd-mZ*>UKy4&s`6+=eS^4A~-`%uyLXM{ubGs6Co za43>!^~9r|SxOhK$+<0FxmN1ZPwKcpv^^HY*idd9k0qyX`f6nF+c|r$&p%T?x-1Nmv!w?8x1H(2)7)w{7*B^=) ziFm*-S`ublNFKj2GwK(OO#yTn236Af&Aw1XEUsR(JMZi;2I7*PRp;MCQXhFI< z)F*k48XQmlkmNaf&_(_i;AeihvEz&6rE4{{tAjO&dGO*cyW_QW!GrB~$Kb~R-0aCH zorUgxYe(<9FjvBvC-07UC+kLkFDwg8;?~-Z%gL+b2kdSNQ>RY$_jH>tie7ROfAnrv z$FZaTm}EQk+1&&be!bKPZ78LtCISWa5XCOV_qv?Za9Ow7YxLd5Y#Cd2|SI#n$ry9fmWG z0XXz`tYUY&`wu{N*xiHCd#O}MyZb|+J5`l;M09sadFLK?FZykt?#@cWHk}Q|^(3X2(@N74Q-?=7 z`2;1sY*)&WY0OFP1WVGric$pD;p-L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YW*i`8)a!Tnx2`kS)z>0yH3rQWnBl&v_FMJ-t($6~Ws}HjE@5t{ z+qTwUXKq`+e&@Odv%$Z%ZXMmpTdZIzEu+N+Si@HHQED2t)-W**fyP)Ex^2}j_;CMa zwgycrl8(RTYitudovK?feKodbjlKy(V#4zDnsaX2lzEv}pjmh)hm58YW+V^~vFGvE za^tSv3jO3q#2g@kI1-b~K~t+4*^hzXFr90XH+SadeddnbY^aF^QYlP@!n?mmJ*qdFk7 -#include -int main () -{ - int c, vysledok, i = 0; - int b[99]; - bool first = true; - bool second = false; + +int main (){ + char riadok[999]; + char *endptr = NULL; + char need; + int i, a, vysledok = 0; + float c[99]; while(1){ - c = getchar(); - if(c == ' ' || c == '+' || c == '\n' || c == '-' || c == '/' || c == '*' || c == '='){ - if(c == '\n'){ - break; - }else if(c == ' '){ - continue; - }else if(c == '='){ - continue; - }else if(c == '+'){ - first = true; - second = true; - continue; - }else if(c == '-'){ - first = false; - second = false; - continue; - }else if(c == '/'){ - first = true; - second = false; - continue; - }else if(c == '*'){ - first = false; - second = true; - continue; - } - }else{ - c = 0; - int r = scanf("%d",&c); - b[i++] = c; - } + char* r = fgets(riadok,999,stdin); + riadok[i++] = *r; + if(*r == '\n') + break; } - if(first == true && second == true) - vysledok = b[0] + b[1]; - else if(first == false && second == false) - vysledok = b[0] - b[1]; - else if(first == true && second == false) - vysledok = b[0] / b[1]; - else if(first == false && second == true) - vysledok = b[0] * b[1]; - if(vysledok == b[2]) + int j = 0; + do{ + if(riadok[j] == ' '){ + j++; + continue; + }else if(riadok[j] == '+'){ + need = riadok[j]; + j++; + continue; + }else if(riadok[i] == '/'){ + need = riadok[j]; + j++; + continue; + }else if(riadok[i] == '-'){ + need = riadok[j]; + j++; + continue; + }else if(riadok[j] == '*'){ + need = riadok[j]; + j++; + continue; + }else if(riadok[j] == '='){ + if(need == '+') + vysledok = c[0] + c[1]; + else if(need == '-') + vysledok = c[0] - c[1]; + else if(need == '/') + vysledok = c[0] / c[1]; + else if(need == '*') + vysledok = c[0] * c[1]; + j++; + continue; + }else{ + float v = strtod(riadok,&endptr); + c[a] = v; + a = a + 1; + } + }while(j < i); + if(vysledok == c[2]) printf("OK\n"); else printf("ZLE\n"); - return 0; } diff --git a/du4/test b/du4/test index db023eb1deb40f2f271db3472a02819551d89fac..406980fca4a9ef0e853cb4dc868dd29aaf6fc0e1 100755 GIT binary patch delta 2425 zcmZ8jYitx%6uvW^otU0PbGY}syWA<`6;M?_31_y8fPP{3%dD^^^RMu-+6p=K$& z#THsDTnqS0^oLP@V2JowjUfv~2_{H`f2!d}jS?4xq^6Si!!mx~%xtrAo4e^&Pp^D;oN;B>kLYy-WN4Go_*M;D8fg^%KC?FQ^sAj}5V_?){Vv8kLK{^3C zA?rMP`0V21G*r{Qnvw36s`Bc?v$B`gjlHpOPs#FIpLsutp6UN)>_`!mXn<71w48x* z&|!YiIHyaVQA+1=*NMk}%YyuG%qu`)tQ+N&5-DGL2X_{5cdu+#@6&g@yzQl~t+G$8 zNj8G3T0T^G<{!>%O{xdCZSzsSh5)1Om}ck*x)aomKzEQLz%Ekoca!2k8&Wrn+(%I8 z8QC>Mh=ZwrP1EencDZuRV5ZI)Pmj=?5J{T|b5RFW&DsQh$ueu{BEjXgap;=0bd{j& z+Ng!;GQn7{Wi3qCi3;MAzzc7-_y3yueWImxeIkxpBqq|D@x-P?8%XXFHvBzg4LMd+ zx#V@IE=c1i^^d+wogB%)ia@ltHuhgl-KaRP#V9mKFN_QgcGZat5%$Y^t$v*)xlGCD zbyVBCoE)*U)Y3I_-SG9ji#+ARX4 zROB|pAa+|~$4V-vF0(nwhO;=#^w_w0p}A>8ZWt;(BQK!2Qa7p&cE%b9PiZ(wdDS#u874oYJzZ6?9GQ^Tk4$U9_wom|Z?FWtyu%$FQBH?SzRw&@1wc`)*egq%HEM zJ2E!``2q073ct~-Hv3%a{_nh+CfLz&%qwz%u`C&cwv!|9(Df*75R+@(A@+tBb9|p> zpov8X&Rz-1OFSEt5%ErR09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JAmb%C-@@7p9bbW4G8~* zqQ_=m1p5<{?9bS+2R3g4pUTEN-SL>X1Z=QR#(xTypjqgQ!-TCX4UO5ALONOM+LJ|7pQLvL$__sDjzPh%$A^OMN+YseD!UD zM^kmBrSG{mY|z(Q$VylqU9-+jn=)_4ax`-<*pSX-+>8WbA@)4^j&0ICTCSgo5itjd zAcn+bbI{OYMh;>iI7w%loeC9Afn*Z%Aon8gK@Y1TL0a_dV7~N}$<3DR F{lDENdi4MR diff --git a/du4/test.c b/du4/test.c index 66d3268..a70c42e 100644 --- a/du4/test.c +++ b/du4/test.c @@ -1,57 +1,17 @@ #include -#include -int main () -{ - int c, vysledok, i = 0; - int b[99]; - bool first = true; - bool second = false; +int main(){ + char riadok[555]; + int i, j = 0; while(1){ - c = getchar(); - if(c <= 255 && c >= 0){ - if(c == '\n'){ - break; - }else if(c == ' '){ - continue; - }else if(c == '='){ - continue; - }else if(c == '+'){ - first = true; - second = true; - continue; - }else if(c == '-'){ - first = false; - second = false; - continue; - }else if(c == '/'){ - first = true; - second = false; - continue; - }else if(c == '*'){ - first = false; - second = true; - continue; - } - }else{ - if(i == 2) - break; - c = 0; - int r = scanf("%d",&c); - b[i++] = c; - } + riadok[i] = getchar(); + if(riadok[i] == '\n') + break; + else + i++; } - if(first == true && second == true) - vysledok = b[0] + b[1]; - else if(first == false && second == false) - vysledok = b[0] - b[1]; - else if(first == true && second == false) - vysledok = b[0] / b[1]; - else if(first == false && second == true) - vysledok = b[0] * b[1]; - if(vysledok == b[2]) - printf("OK\n"); - else - printf("ZLE\n"); - return 0; + do{ + printf("%c\n", riadok[j]); + j++; + }while(j < i - 2); }