From fb9c572281fb371982f1619bd7be7654973441fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dami=C3=A1n=20Korpesio?= Date: Mon, 3 Jan 2022 18:28:22 +0100 Subject: [PATCH] prvy --- sk1a/main.c | 10 ++++---- sk1a/main.o | Bin 7496 -> 7496 bytes sk1a/maze.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++---- sk1a/maze.o | Bin 6168 -> 7168 bytes sk1a/program | Bin 21504 -> 21856 bytes 5 files changed, 68 insertions(+), 10 deletions(-) diff --git a/sk1a/main.c b/sk1a/main.c index 38c5fb1..95139d5 100644 --- a/sk1a/main.c +++ b/sk1a/main.c @@ -15,11 +15,11 @@ void print_solution(char* matrix,int sz){ int main(){ char tmaze[SZ+1][SZ+1]={ - "*x ", - " x ", - " x ", - " x ", - " ", + "*x ", + " xx ", + " x ", + " x ", + " ", }; char maze[SZ*SZ]; memset(maze,' ',SZ*SZ); diff --git a/sk1a/main.o b/sk1a/main.o index c7ee5e6006153994a325d6ef54c9f7e5f9936277..f4a04da47028ca2258417e4ab71bd822e31d3527 100644 GIT binary patch delta 29 lcmX?Mb;4=`GowI7g+khK*HsD($6ePbC@55H7G^Y+0RW;f3B3RS delta 29 jcmX?Mb;4=`Goye)g+khK*HsD($6ePb06Ck58BJvXn@|a5 diff --git a/sk1a/maze.c b/sk1a/maze.c index d078bb5..98825c2 100644 --- a/sk1a/maze.c +++ b/sk1a/maze.c @@ -5,21 +5,79 @@ int solve_maze(char* maze,int size) { int i = 0; + int p, l, h, d = 0; while(i != size*size-1){ - if (maze[i + 1] == ' ' && i != size - 1) { + if (maze[i + 1] == ' ' && i != size - 1 && l != 1) { maze[i + 1] = '*'; i++; - } else if (maze[i + size] == ' ' && i != size - 1) { + p = 0; + l = 0; + h = 0; + d = 0; + } else if (maze[i + size] == ' ' && i != size - 1 && h != 1) { maze[i + size] = '*'; i = i + size; - } else if (maze[i - 1] == ' ' && i != 0) { + p = 0; + l = 0; + h = 0; + d = 0; + } else if (maze[i - 1] == ' ' && i != 0 && p != 1) { maze[i - 1] = '*'; i--; - } else if (maze[i - size] == ' ' && i > size) { + p = 0; + l = 0; + h = 0; + d = 0; + } else if (maze[i - size] == ' ' && i > size && d != 1) { maze[i - size] = '*'; i = i - size; + p = 0; + l = 0; + h = 0; + d = 0; + } + else{ + while(1){ + + if (maze[i + 1] == ' ' && i != size - 1 && l != 1) { + i++; + break; + } + if (maze[i + size] == ' ' && i != size - 1 && h != 1) { + i = i + size; + break; + } + if (maze[i - 1] == ' ' && i != 0 && p != 1) { + i--; + break; + } + if (maze[i - size] == ' ' && i > size && d != 1) { + i = i - size; + break; + } + p = 0; + l = 0; + h = 0; + d = 0; + if (maze[i + 1] == '*' && i != size - 1) { + maze[i] = ' '; + i++; + p = 1; + } else if (maze[i + size] == '*' && i != size - 1) { + maze[i] = ' '; + i = i + size; + d = 1; + } else if (maze[i - 1] == '*' && i != 0) { + maze[i] = ' '; + i--; + l = 1; + } else if (maze[i - size] == '*' && i > size) { + maze[i] = ' '; + i = i - size; + h = 1; + } + } } } - return 1; } diff --git a/sk1a/maze.o b/sk1a/maze.o index c8ded7d6b8be0c4d081989d6fd0006f97bb1a1b0..d13f7c74de8d99ad916ac41fd46ed5bc7aa29d1a 100644 GIT binary patch delta 1812 zcmah|O=ufe5Pt8i$NI@uYiXsGH+G0Z1W6>?x`sG*Evq5*(yg7AP+D+IP1`h;QfQzA zEtG(>A*xG@lOnShABw5(hK7iSf)8y8L=EKNQXO(kE+wKm7~_Kvrs}-+Wa|f$?qO%= z%{SkhZ)SFR=;mnYBqQ;q)G_zTcTTlp)d@ZoYnPi^P9bE`s@u!L%UBh z3Fqxat6F?c$E|wZstN$axlH6&l+Nw&n z2rsISTh$w9i}Sm*@H%=OAX)mU{nFivbx@1`rmfmLM{u~+A5DxP!24bMnI|-R+FjCM zDcGTXNC3UEgShFb^$x$*VM}4&<;$Ji$ zxjAm zpK^{1`A52wQEojbC_h?!g@XDLwc_h@T%2mA~4bRi*q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