domaca_uloha_7
This commit is contained in:
parent
886dcc0079
commit
1f52f19175
@ -24,7 +24,7 @@ struct snake* remove_snake(struct snake* snake){
|
||||
}
|
||||
|
||||
else { //inak prebehnem celého hada od začiatku
|
||||
struct snake* medzipamat = calloc(1, sizeof(struct snake)); //alokujem medipamäť
|
||||
struct snake* medzipamat = calloc(1, sizeof(struct snake)); //alokujem medzipamäť
|
||||
medzipamat = snake; //adresu hlavy hada uložím do medzipamäte
|
||||
|
||||
while (snake->next->next != NULL) snake = snake->next; //hada budem prezerať dovtedy, kým nenájdem jeho koniec
|
||||
@ -51,11 +51,10 @@ void free_snake(struct snake* sn){ //funkcia odstráni hada z hry
|
||||
int is_snake(struct snake* snake,int x,int y){
|
||||
if (snake == NULL) return 0;
|
||||
|
||||
do {
|
||||
while (snake != NULL) {
|
||||
if (snake->x == x || snake->y == y) return 1;
|
||||
snake = snake->next;
|
||||
|
||||
} while (snake->next != NULL);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user