domaca_uloha_7

This commit is contained in:
Tomáš Vasiľ 2022-04-26 21:14:38 +02:00
parent 4d74b16736
commit bd05b81d3e

View File

@ -18,11 +18,23 @@ struct snake* add_snake(struct snake* snake,int x,int y){
struct snake* remove_snake(struct snake* snake){
if (snake == NULL) return NULL;
struct snake* nasledujuci = calloc(1, sizeof(struct snake));
nasledujuci->next = snake->next;
free(snake);
else if (snake->next == NULL) {
free(snake);
return NULL;
}
return nasledujuci;
else {
struct snake* medzipamat = calloc(1, sizeof(struct snake));
medzipamat = snake
while (1) {
snake = snake->next;
if (snake->next->next == NULL) break;
}
free(snake->next->next);
snake->next = NULL;
return medzipamat;
}
}
void free_snake(struct snake* sn){