深度优先搜索
#include<cstdio>
#include<iostream>
using namespace std;
#include<cstring>
#include<algorithm>
#include<queue>
#define N 100
int move[4][2]={
0,1,1,0,0,-1,-1,0
};
struct node
{
int x,y,step;
}fa[N][N],road[N*N];
struct node start,next,head;
queue<node>Q;
int n,m,sx,sy,dx,dy;
char a[N][N];
int vis[N][N];
int can[N][N];
void bfs(int x,int y)
{
vis[x][y]=1;
start.x=x;start.y=y;
Q.push(start);
while(!Q.empty())
{
head=Q.front();
Q.pop();
/* printf("-->%d %d",head.x,head.y);
printf("n");*/
if(head.x==dx&&head.y==dy)return;//找到终点,return
for(int i=0;i<=4;i++)
{
next.x=head.x+move[i][0
本文发布于:2024-02-05 01:30:15,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170720953361801.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |