(c语言)贪吃蛇小游戏,一运行就gameover

问题遇到的现象和发生背景 写的贪吃蛇小游戏,一运行就game over了 ,为什么?请问哪里出现问题?感谢!
#include
#include
#include<time.h>
#include
#include 
struct Node
{
int x ,y;
struct Node * pre;
struct Node* next;

};
struct Food
{
int x, y;
char c;
};
int main()
{
int a[20][20] = { 0 };
int m, n, t, flag = 0;
char c = 'd', cl = 'd';
struct Food food = { 1,2,'A' };
int gameover = 0;
struct Node* head, * p, * rear, * pt;
head = (struct Node*)malloc(sizeof(struct Node));
head->x = 1;
head->y = 2;
head->pre = NULL;
head->next = NULL;
rear = head;
srand((unsigned)time(NULL));
while (1)
{
if (food.x == head->x && food.y == head->y)
{
p = (struct Node*)malloc(sizeof(struct Node));
pt = head;
while (pt->next != NULL)
pt = pt->next;
p->pre = pt;
pt->next = p;
p->next = NULL;
rear = p;
food.x = rand() % 20;
food.y = rand() % 20;
food.c = 'F';
flag = 1;
t = 0;
while (flag == 1)
{
if (t > 5)
break;
flag = 0;
pt = head;
while (pt != NULL)
{
if (food.x == pt->x && food.y == pt->y)
{
flag = 1;
food.x = rand() % 20;
food.y = rand() % 20;
break;
}
pt = pt->next;
}
t++;
}
if (t > 5)
{
if (c == 'd')
{
food.x = head->x + 1;
food.y = head->y;
if (food.x >= 20)
food.x -= 20;
}
else if (c == 'a')
{
food.x = head->x = 1;
food.y = head->y;
if (food.x < 0)
food.x += 20;

}
else if (c == 'w')
{
 food.x = head->x ;
 food.y = head->y+1;
if (food.y >= 20)
 food.y -= 20;
}
else if (c == 's')
{
food.x = head->x;
food.y = head->y = 1;
if (food.y < 0)
 food.y += 20;
}
}

}
if (_kbhit())
{
cl = _getch();
if (cl == 27)
break;
if (c != 'd' && cl == 'a')
c = cl;
else if (c != 'a' && cl == 'd')
c = cl;
else if (c != 'w' && cl == 's')
c = cl;
else if (c != 's' && cl == 'w')
c = cl;
}
pt = rear;
while (pt != head)
{
pt->x = pt->pre->x;
pt->y = pt->pre->y;
pt = pt->pre;
}
if (c == 'd');
{
head->y += 1;
if (head->y >= 20)
head->y -= 20;
}
if (c == 'a');
{
head->y -= 1;
if (head->y <0)
head->y += 20;
}
if (c == 'w');
{
head->x -= 1;
if (head->x < 0)
head->x -= 20;
}
if (c == 's');
{
head->x += 1;
if (head->x >=20)
head->x -= 20;
}
pt = head->next;
while (pt != NULL)
{
if (head->x == pt->x && head->y == pt->y)
{
gameover = 1;
break;
}
pt = pt->next;
}
if (gameover == 1)
break;
system("cls");
for (m = 0; m < 20; m++)
{
for (n = 0; n < 20; n++)
{
flag = 0;
pt = head;
while (pt != NULL)
{
if (m == pt->x && n == pt->y)
{
if (pt == head)
printf("H");
else
printf("b");
flag = 1;
break;
}
pt = pt->next;
}
if (flag == 0);
{
if (m == food.x && n == food.y)
{
putchar(food.c);
continue;
}
printf(" ");
}
}
putchar('\n');
}
Sleep(200);
}
if (gameover == 1)
puts("game over !!!\n");
getchar();
return 0;
}


124-142行判断字符aswd的if,180行后面的分号删了。