LINZJ0622 @ 2023-12-07 22:22:02
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int m, n, flag = 0,ret = 0;
char a[100][100];
int v[100][100] = { 0 };
int xx[4] = { 0,0,-1,1 };
int yy[4] = { 1,-1,0,0 };
void dfs(int x, int y)
{
int X = 0;
int Y = 0;
int i = 0;
if (x == n && y == m)
{
flag = 1;
ret = 1;
return;
}
v[x][y] = 1;
for (i = 0; i < 4; i++)
{
X = x + xx[i];
Y = y + yy[i];
if (a[X][Y] == '.' && X > 0 && X <= n && Y > 0 && Y <= m && v[X][Y] == 0)
{
dfs(X, Y);
if (ret)
{
return;
}
}
}
return;
}
int main()
{
int i = 0;
int j = 0;
scanf("%d %d", &n, &m);
for (i = 1; i <= n; i++)
{
for (j = 1; j <= m; j++)
{
scanf(" %c", &a[i][j]);
}
}
v[1][1] = 1;
exit:
dfs(1, 1);
if (flag)
{
printf("Yes");
}
else
{
printf("No");
}
return 0;
}
by diandian2020 @ 2023-12-07 22:24:59
数组开小了
by uiuiuyuguo433 @ 2023-12-07 22:34:25
@LINZJ0622 你开100的数组是0-99,他有一百的数据
by IAKIOI_everyday @ 2023-12-09 22:37:03
你数组应该开到105