询问一道关于BFS搜索的编程问题~

img


#include<stdio.h>
#include<string.h>
#include<queue>
using namespace std;

const int maxn=1005;
char mpt[maxn][maxn];//存储迷宫地图
int vis[maxn][maxn];//访问标记数组
int dir[4][2]={0,1,1,0,0,-1,-1,0};//代表方向
int m,n,k;
struct node
{
    int x,y;
    int t;//处于(x,y)时转了t次
}s1,s2;

bool bfs()
{
    memset(vis,0,sizeof(vis));
    queue<node>q;
    s1.t = -1;//第一次转弯不计入,次数设置为-1
    q.push(s1);
    while(!q.empty())
    {
        node now=q.front(); q.pop();
        if (now.t)  return false;
        if(now.x == s2.x && now.y == s2.y)//若到达终点
             return true;
        for(int i=0;i<4;i++)//若未到达,则尝试不同方向
        {
            node next;
            next.x=now.x+dir[i][0];
            next.y=now.y+dir[i][1];
            next.t=now.t+1;
            if(next.x>0&&next.x<=n&&next.y>0&&next.y<=m&&mpt[next.x][next.y]!='*'&&next.t<=k)
            {
                if (!vis[next.x][next.y])
                {
                    q.push(next);
                    vis[next.x][next.y]=1;
                }
            }
        }
    }
    return false;
}

int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d%d",&m,&n);
        if(m==0&&n==0)  break;
        memset(mpt,0,sizeof(mpt));
        for(int i=1;i<=m;i++)  scanf("%s",mpt[i]+1);
        scanf("%d%d%d%d",&k,&s1.x,&s1.y,&s2.x,&s2.y);
        s1.y--; s1.x--; s2.y--; s2.x--;
        bool flag = bfs();
        if (flag) printf("yes\n");
        else printf("no\n");
  }
  return 0 ;
}

不知道哪里出了问题,第二组没输入转弯数和坐标就直接输出no了

img

59行,格式化字符串有4个%d,而参数有5个。