From 2b4de3b562e8569cace518dc352134760ce8b81f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Gejdo=C5=A1?= Date: Tue, 14 Apr 2026 15:43:58 +0000 Subject: [PATCH] zbytok --- du4/snake.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/du4/snake.c b/du4/snake.c index 4e2df6c..e83009a 100644 --- a/du4/snake.c +++ b/du4/snake.c @@ -35,10 +35,30 @@ struct snake* remove_snake(struct snake* snake){ } void free_snake(struct snake* sn){ + + if (sn == NULL) return; + + struct snake* clanok = sn; //idem pozerat kde su clanky + + do { + clanok = sn;//nacitam aktualny clanok + sn = sn -> next;//posuniem sa o clanok + free(clanok);//vycistim staru ulozenu poziciu + } while (sn -> next != NULL) + } int is_snake(struct snake* snake,int x,int y){ - return 0; + + struct snake* clanok = snake;//zase idem pozerat po clankoch ci som na hadovi v koordinatoch + + while (clankoch != NULL) { // usetrim si podmienku ci nahodou nedostanem NULL hada + if (clanok -> x == x && clanok -> y == y) { + return 1; // mam vratit true/false, ale dostal som int funkciu, bool true false je aj tak iba jeden bit 1 alebo 0 + } + clanok = clanok -> next; + } + return 0; //defaultne vratim 0 ked nenajdem hada } int step_state(struct state* st){