From 415e7d9678c115aedd610a967b9f45290dbe7e19 Mon Sep 17 00:00:00 2001 From: vj586da Date: Sun, 9 Jan 2022 01:11:43 +0100 Subject: [PATCH] first commit --- skuska/sk1a/Makefile | 14 ++++++++++ skuska/sk1a/main.c | 39 ++++++++++++++++++++++++++ skuska/sk1a/main.o | Bin 0 -> 5208 bytes skuska/sk1a/maze.c | 64 +++++++++++++++++++++++++++++++++++++++++++ skuska/sk1a/maze.h | 22 +++++++++++++++ skuska/sk1a/maze.o | Bin 0 -> 3440 bytes skuska/sk1a/program | Bin 0 -> 18816 bytes 7 files changed, 139 insertions(+) create mode 100644 skuska/sk1a/Makefile create mode 100644 skuska/sk1a/main.c create mode 100644 skuska/sk1a/main.o create mode 100644 skuska/sk1a/maze.c create mode 100644 skuska/sk1a/maze.h create mode 100644 skuska/sk1a/maze.o create mode 100755 skuska/sk1a/program diff --git a/skuska/sk1a/Makefile b/skuska/sk1a/Makefile new file mode 100644 index 0000000..ae923d1 --- /dev/null +++ b/skuska/sk1a/Makefile @@ -0,0 +1,14 @@ +all: program + +maze.o: maze.c + gcc -c -g -Wall maze.c -o maze.o + +main.o: main.c + gcc -c -g -Wall main.c -o main.o + +program: maze.o main.o + gcc -g -Wall maze.o main.o -o program + +clean: + rm program + rm *.o diff --git a/skuska/sk1a/main.c b/skuska/sk1a/main.c new file mode 100644 index 0000000..091005a --- /dev/null +++ b/skuska/sk1a/main.c @@ -0,0 +1,39 @@ +#define SZ 5 +#include +#include +#include "maze.h" + +void print_solution(char* matrix,int sz){ + for (int i = 0; i < sz * sz; i++){ + printf("%c ",matrix[i]); + if (i % sz == (sz-1)){ + printf("\n"); + } + } +} + +int main(){ + char tmaze[SZ+1][SZ+1]={ + "*x ", + " x ", + " x ", + " x ", + " ", + }; + char maze[SZ*SZ]; + memset(maze,' ',SZ*SZ); + for (int i= 0; i < SZ; i++){ + for (int j= 0; j < SZ; j++){ + if (tmaze[i][j] == 'x'){ + maze[i*SZ+j] = 'x'; + } + } + } + int r = solve_maze(maze,SZ); + if (!r){ + printf("Nenasiel som riesenie\n"); + } + print_solution(maze,SZ); + + return 0; +} diff --git a/skuska/sk1a/main.o b/skuska/sk1a/main.o new file mode 100644 index 0000000000000000000000000000000000000000..b67a4f16a6cf21930c45de96cb081640e7d813e6 GIT binary patch literal 5208 zcmbtWeOQy%6~7?~AZS1)isI;tf<>tzI36nwDghFrpn!_f>Ka1`kV*n2L4gOT6hDZF zpu-L=4};dBwN{ZKYWZkD%7?YeaNC2nT1s)l${y`pEpA$O&zpNOyud%(d7k$@_xC&J z+;i`_=lys`7A3dg@emardJVlmltrjQ^kN*s4nxo!G#kY!Om`K9BaFh7H*Crr>XJPL z<9$W3?5RTCi`B4#*Xz`XoLbGMPDP0jtO`@tMbN`=!;VLP${Q+{4HXXa0^2hkK69X^ zLfKOu=AF)(17%NhKPfBgxlGcfCn|~s-agn-VUmsdn-yKMY77w8CyA~jn$6TDGXun4 zOR^XysY`a8!Jw95vH+X{aGHQR0QCek0=URv!EVhAQk2MgKb?zbYGv>Z?}Ob!m#iEk zbbnKqtb!ec70W6V>h5A$In=<^tKgY&71%p2N4KJIcpENBP*&#b;<$2CZ`*(kuN{YA zmx|7CVQ*F;9v9|S2=Xr!%F6MmT#$bpQny0+XjYS~vM{d_Wjej6D!ZBqj%)=K#c`vF z3g205(TqaYv*)t6nnCL{dX+(|No5RaIwnJ_F=+H!%~%h7N1B25L{??f^=`BIin+TD z3AQq!@9}1gsKe_nNd@<1Z~HQzcejZK{p)uv_7KU7JP$-UtK`e=OI^c%sIN=<+Yxkr zS9av$elwNgl<_$`ZSLmJu?fP?U*-5*o{i~h4K6hFWpX-(# z61r2`{z*vaE~)c~AiwUAWWec1(RY;rjN?cm&$&2zaCeR*y4ki{eQemgwWHcRt*Y z9C!Dt4Y{@z8}@iE>lx_PeODjfQ#fWIxl{_DqXyT9sx!W<3^aY5N4@2zO8KAscm z6IXgk)Gl!jPxfE5$nly=VDecIIscad0Rln8&o95`kro=0vQwURr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tsGi(=;iK9=Am9R5v$;e7`}=Q(JBD3EB%A0hZP4qr)d7>ECmU-Gt$yE8OCffuO>yAl%djT$VUH9#o&0TE$uft zT?iR)e{)H@Qa9v|N6?=kV~k}m3WtcL-=fegtRa@r$c^yOpTNVn#ae#mCL%^I4Sf!C z{;%==I2Pu#?jZ~j%}?Lsz=3e{L;tfJ-5BeIkQ4UW1p+Z>emY&F)Y<&9;hFj z5sjzyTZ6gD@~4XP{#@U9Y?y5Q>EuOE<6-@2+bdwa|FVrQ*S4`Kw9(hr|)`!(Szhr}^_R2l*w`fX5)CB>yQ39J^CD zT8AQRnJoS!`Kh4aSvmnXzJkV62clmk59BX6Jk3jW4TVFOo;9JV= z{}>Wa&yV`k^;6t~2QVi$eiw;{{;(Eqd#m_uT>UMI@0HfR%9THxt_?i#L`~>AvgZNADKYu literal 0 HcmV?d00001 diff --git a/skuska/sk1a/maze.c b/skuska/sk1a/maze.c new file mode 100644 index 0000000..c9a4c2f --- /dev/null +++ b/skuska/sk1a/maze.c @@ -0,0 +1,64 @@ +#include +#include +#include "maze.h" +#include +#include + +int solve_maze(char* maze, int size){ + for(int i = 0; i < size * size; i++){ + if(maze[i] == ' '){ + maze[i] = '*'; + continue; + }else{ + i = i+size-2; + continue; + } + } + return 1; +} + +/*int solve_maze(char* maze,int size){ + + char smaze[size+1][size+1]; + char* wmaze = smaze; + int k = 0; + memset(smaze, 0, size); + for (int i = 0; i < size; i++) { + for (int j = 0; j < size; j++) { + smaze[i][j] = maze[k]; + k++; + } + + } + + for (int i = 0; i < size; i++) { + for (int j = 0; j < size; j++) { + printf("%c ",smaze[i][j]); + + } + printf("\n"); + } + + + int r = findWay(0,0,size); + + return r; +} + + + + +int findWay(int i, int j, int size){ + + if(wmaze[i][j] == ' '){ + + wmaze[i][j] = '*'; + if(findWay(i, j+1, size) == 1) return 1; + if(findWay(i+1, j+1, size) == 1) return 1; + + wmaze[i][j] = ' '; + } + return 0; +} + +*/ diff --git a/skuska/sk1a/maze.h b/skuska/sk1a/maze.h new file mode 100644 index 0000000..2e34662 --- /dev/null +++ b/skuska/sk1a/maze.h @@ -0,0 +1,22 @@ +#ifndef _MAZEH +#define _MAZEH + +/** + * Funkcia by mala zobrať vstupnú mriežku a + * vyznačiť na nej cestu z ľavého horného rohu do pravého dolného rohu. + * Mriežka je uložená do jednorozmerného poľa, pričom najprv ide prvý riadok, + * za ním druhý a tak ďalej. + * + * Na mriežke sa nachádzajú znaky: + * ' ' - voľné miesto + * 'x' - stena. Stena nesmie byť prepísaná. + * '*' - poloha potkana. Na začiatku je na 0,0. + * + * @param maze Štvorcová mriežka rozmeru size x size. + * @param size Rozmer mriežky + * @return 1 ak existuje riešenie, 0 inak. + */ +int solve_maze(char* maze,int size); + + +#endif diff --git a/skuska/sk1a/maze.o b/skuska/sk1a/maze.o new file mode 100644 index 0000000000000000000000000000000000000000..eac353ebeedeb52af4eb000bab8a299b77815e2e GIT binary patch literal 3440 zcmbVOZ%k8H6u+;3p!kp$%9P5S^$!YEi-60lPNlLU2pDxj)McYBJPQsAE5#t2bBJzs z#KmQzs6@LBj8o^IINh@Op|}l!G0NtakbUw4Ocs}AW?8Z&B-_1@b8363U%bidJ-^>Q zzkANR=ib}5-&Rtf5CnovAZy7Zge)P;HIM8(*~}wPkz`U<=o>He?VIp5joqZK6;Z(cUD_8=I0MxIU8kK-*q6*=`#XM%pG6KHKEcHru2?vGz*9Vw-&9 z))y>^m%k3>@{1gkgm81$SABs%U@*`xbfCIlRG{>$%#NF-xQVp|4*xe$Co^ z$@uP}L(k@3QJoitD#!b+TYGOSvc(eX!O0wD@DQ6{XKFRY#)YY~g|iWEYWi9%X}UR2IY zotG#i#p-4gq5=V3GPRa!i}ZxVn1yu)sufp@7IBH8NY9+}Qd$gz#EJp~glJX}rDn=w zYHs?@Sc~P;-v6${Znry$kPuU)3%)g%kfeL$c*y_EH2>4z%InqZS9co>hW&p%Jdj?X z(=Ih?ojJ?12Xi0hW(S0enaU+yrryCD$2&eb*in48<8QqwR;d?1e$J#lysCFl@lov# zOKb86f+_XzZiSfBb3L;y{nt!&dB)KNS>+C0N8jMUkfC=lW#AjtXU`DDPV7E?=G2Lu$4X%cp|F&0Tkc{lU_ovxBRPhYBxX7(^Kp;i#mDgR(|Gm@Nn!b5T}Yjy zMKV{C#`@YlQUwE3QhenZ6o#+oOqiMREZbthNnt!adL#|-ERF|A=77Q0Pk|)uGr?x_ zvzlVd1_R^L^C`EL9FLlH9G?Zafa6;Mmva0uz}qqIxE44bvm%oABPrz!Ted>mjcEf`7OYQ z*OB>e2Yxm5{QO4X6|`qhsF@r0)_EOHVs7+$ruu5Myi&85n5!IK2QfPv8;RK?)jG^o zlC#NGQRCiKPse22;dFYWJrTnWkHhVfA|H*}$xLsd zWsP1(<*R^Q?k01Cr@le*c=tjqsk&m9$5AJRUgpV-R4Qd_hIPZ4^1uk4bHL0uyv?V8 zapARQ<7e4Vl*a3qP#<AvbnD`FCOi3xRxH_ImWg`);N~GKUj`s~;Tk-oY6-H~IdImVW>Wihp!0e|BC_ zkNHrditpt(J(Id?4CzE+_8q=&@jmRc2l0!CE{+PxB>K7 zKahv=M|_JKY))S92mMNPgdX1?>CdSVt$v$XQnX>6Sp9VLK|S)(Vl&++#2;mVHnxsT j%j?;mh_+N$SyHq;ZvCf52}z_zG<`MX--nLS^XvaV8@O|U literal 0 HcmV?d00001 diff --git a/skuska/sk1a/program b/skuska/sk1a/program new file mode 100755 index 0000000000000000000000000000000000000000..dbdbbc9b9ea463e9835c9879fc70665eacf1fcfa GIT binary patch literal 18816 zcmeHP4{#LMd4IciE1eKJ35h@AkF5n;Hg=*D;-A4-<^&v^Y=K=24sMK>)7?orTe?&3 z_J|;0G?wGBD&vBOwsy;;beg6~rk;|flQJ!J1himxrZc#m@i=Z0Ycf!a+I5NZrzF9? z{=T>GJN6bSO*_-hv~y3h`+MK-ec$)q`}Xbb+r51{6zSTmYntHX6ZZ>}hU*+AtO|xX z134_#h#Kr~7q^KD$bQLTHwC_}J3M2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