一个M*N的矩形,给出出发点@,求能不能通到批定点!。#代表墙,不能过,每次移动只是上下左右,不能出界,

#include<iostream>
#include<stdlib.h>
#include<math.h>
#include<stdio.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>

using namespace std;

char go[100][100];
bool hi[100][100];
int m,n;
int c,d;

bool in(int a,int b)
{
    if (a<0||a>=m)
        return false;
    if (b<0||b>=n)
        return false;
    return true;
}

bool make(int a,int b)
{
    cout<<a<<' '<<b<<' '<<go[a][b]<<endl;
    int i,j,k;
    if (go[a][b]=='#')
        return false;
    if (go[a][b]=='!')
    {
        //cout<<"The big one:"<<a<<' '<<b<<endl;
        return true;
    }
    go[a][b]='#';
    bool A,B,C,D;
    A=B=C=D=false;
    if (in(a+1,b))
        A=make(a+1,b);
    if (in(a-1,b))
        B=make(a-1,b);
    if (in(a,b+1))
        C=make(a,b+1);
    if (in(a,b-1))
        D=make(a,b-1);
    return A||B||C||D;
}

int main()
{
    freopen("fuck.txt","r",stdin);
    int a,b;
    int i,j,k;
    while (cin>>m>>n)
    {
        gets(go[0]);
        for (i=0;i<m;i++)
        {
            cin>>go[i];
            //cout<<go[i]<<endl<<endl;
        }
        memset(hi,0,sizeof(hi));
        for (i=0;i<m;i++)
        {
            for (j=0;j<n;j++)
            {
                if (go[i][j]=='@')
                {
                    a=i;
                    b=j;
                }
                if (go[i][j]=='!')
                {
                    c=i;
                    d=j;
                }
            }
        }
        if (make(a,b))
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
}