From 2fa7918d0ba1069d238bdd1978044e6209ca72bb Mon Sep 17 00:00:00 2001 From: Anton Date: Tue, 29 Oct 2024 17:55:12 +0100 Subject: [PATCH] Initializacia --- a1/main | Bin 16336 -> 16416 bytes a1/program.c | 19 +++++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/a1/main b/a1/main index f534ddc294f0d7c03622541afe8241e288ce91e9..c4fcfac18b07659e0c16f2df788301212a8f0596 100755 GIT binary patch delta 2707 zcmZ`*e@qld6rQ=`4o<+kJ;3!8y*rEwDz_X$LEr>Lbct;cqm5OJP@qCYMLD9jnnMv& zf+mNrHMVK(Y161}+DhmT{-_qC)fhF!MynK%U;}pn^8V~o3P%0jCmVvsT_M@uBlBC2)RwD8ek;I0Ec!Ih*&VA9fA4_H=8@Syvp}|5h!s}?Wrq?h=GsytI zR|k02IBy^!C^pZe23Thn9Y!u@5H8dVc4I8?zFCBe=D7ICC^i-@nMH4$CR49RxtDDL zRzJNRAH_$(Q;an$IxfC%6l;d`Xb~!r?H|R)^i)T$joD{QiP<&L(|*=(@AF%f0jsl>2~TrG{V`RaeHa!A$+QmYg~@5_ zkRmNJm&t9ud8{jU-0{cBoxTNVgwOw@DB)UM$5~S;d@kH9>WI8q`owy&^hsOf4Sxz= z0-0@*m3}8)0;z40RDX0^q`)r@CHJObtf2|L+ZiPEu3`|^I~VQ=iO^}!p45-`MeaD) zi#!Q;K2?-+?cY366lM+x~- z_CD*bL#S*!(Tk+glFHqkZ?m8sXEDO0(GxP&pdG_>wzIB$!1~pD-}PbdS=dAjn|nI8 z#nSdElhC13xRM}Ex{A-)NZv9FbC}JmCQo6&J}$7U&)R+%2Wz>IEp<5gm!n5f95s~p zZ022j=003ZFIK{OvQN$U-O+IecP@)y>_k1b@<>t6pYEBG`SAchgyWD&%E#O3!CWeZ~QFz!f1KVl5t zz$1vMh>sCv#Pa*Gic*iALk|^Y5B%+#POpR8Et&@YP?RR{xu?)nsCJ7E7Y44vKzd8Y z&K~?%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1iSL60YpTkxm zjds96Aw8!DDY7efZKyr4kxfILKet#yU4hLg#Ks@Va;!m?&F}Q6@xA!WBN?Z%G{)xbRdz#RMX2qks%tut_M|_3p(BI6-H-{}Lu=&iH!f2slG(jrE2}5 zxC0~hb_6Z2j$%Ys9HI8RrcnC@)966`!fOeKUAx=X?$}=6vZ<-D z!L{*?`b}FKTU?o&T+KUNnGFdfxNV!t?sTnuF8=lsI$vAH&Ix>xNbB#id=POA@f2bV zkv*N_Nm+gk(LE*06Nq()>@0W((S>*uu?kVXua)HnpziDiBj}oirli^!e|s}<>cbxU zO_n!6jeC*Tg%;|I%?$0>Td=1hzlssOr6G1>FM%U&C!Q)pIIf2o_xvSykp)aGgB@Ts zPgvj9EK4$k+O=An#$q%P!aS{*7Tg=CSolIBoHBYG>Jbp;M**tiZ4I2va|#(LisayI z6vp$Mv=3(TB+axAmgJ|?QCOZY2~qw+^P`irLTA2Hm}KV#Hh$WZR2a%%Nyoq}Iq5Lu zNLy$>^h%X5CS7+}c>;}ny08(QL#1}_y309l~l#a+2Kc)IXy*?Wq7%X~;4rKcGQW(+b2l|RPQ0f9& zDhbm(Efq&0i0m-`%&V9Rky6P##@R6#D)pOFdBLQ@OsRjieAF^(gwg3PC diff --git a/a1/program.c b/a1/program.c index 4cd5e11..c936066 100644 --- a/a1/program.c +++ b/a1/program.c @@ -26,6 +26,16 @@ char matching_bracket(char ch) { } } +char expected_closing(char ch) { + switch (ch) { + case '(': return ')'; + case '{': return '}'; + case '[': return ']'; + case '<': return '>'; + default: return 0; + } +} + void check_brackets(const char *line) { StackItem stack[MAX_LEN]; int stack_top = -1; @@ -51,14 +61,19 @@ void check_brackets(const char *line) { stack_top--; } else { printf("Crossed bracket %c in %d, expected %c\n", ch, i, - matching_bracket(stack[stack_top].bracket)); + expected_closing(stack[stack_top].bracket)); return; } } } if (stack_top >= 0) { - printf("Unmatched bracket %c in %d\n", stack[stack_top].bracket, stack[stack_top].position); + printf("Missing closing brackets:"); + while (stack_top >= 0) { + printf(" %c", expected_closing(stack[stack_top].bracket)); + stack_top--; + } + printf("\n"); } else { printf("All brackets OK\n"); }