#include <algorithm> //STL通用算法
#include <bitset> //STL位集容器
#include <cctype> //字符处理
#include <cerrno> //定义错误码
#include <clocale> //定义本地化函数
#include <cmath> //定义数学函数
#include <complex> //复数类
#include <cstdio> //定义输入/输出函数
#include <cstdlib> //定义杂项函数及内存分配函数
#include <cstring> //字符串处理
#include <ctime> //定义关于时间的函数
#include <deque> //STL双端队列容器
#include <exception> //异常处理类
#include <fstream> //文件输入/输出
#include <functional> //STL定义运算函数(代替运算符)
#include <limits> //定义各种数据类型最值常量
#include <list> //STL线性列表容器
#include <map> //STL 映射容器
#include <iomanip> //参数化输入/输出
#include <ios> //基本输入/输出支持
#include<iosfwd> //输入/输出系统使用的前置声明
#include <iostream> //数据流输入/输出
#include <istream> //基本输入流
#include <ostream> //基本输出流
#include <queue> //STL队列容器
#include <set> //STL 集合容器
#include <sstream> //基于字符串的流
#include <stack> //STL堆栈容器
#include <stdexcept> //标准异常类
#include <streambuf> //底层输入/输出支持
#include <string> //字符串类
#include <utility> //STL通用模板类
#include <vector> //STL动态数组容器
#include <cwchar> //宽字符处理及输入/输出
#include <cwctype> //宽字符分类
using namespace std;
# define PI 3.141 //圆周率
# define Gen2 1.414 //根号2
# define C 299792.458 //光速 光速为299792.458km/s
# define E 2.718 //e(自然对数函数的底数) //好吧我承认前面就是凑字数的 //后面才是核心
int a[15][15],i,j,k,t; int dx[5]={-1,0,1,0},dy[5]={0,1,0,-1}; bool b[15][15],f=0; long long int c[12]={72,101,108,108,111,44,87,111,114,108,100,33}; //别问为什么要用long long int,问就是帅
struct kunkun //特有的ikun结构体 能够存放搜索时需用到的二维数组的下标
{ int x; int y; }; void bfs(int x,int y) //广搜函数 用来在二维数组里寻找Helloworld的ascall值 虽然自己都有些弄不清楚
(doge) { queue<kunkun> q; //广搜特有的队列 kunkun p; //将当前搜索的值的下标放到队列里
p.x=x; p.y=y; q.push(p); if(a[q.front().x][q.front().y]==c[k]) //判断 如果找到当前目标就输出 { f=1; //标记有没有找到
cout<<char(a[q.front().x][q.front().y]); //输出
if(char(a[q.front().x][q.front().y])==',') cout<<" "; return; } while(!q.empty()) //开始搜索 队列空了就不能再搜索
{ for(i=0;i<4;i++) { int x2=q.front().x+dx[i],y2=q.front().y+dy[i]; //下一次搜索的下标
if(x2>0&&y2>0&&x2<14&&y2<14&&b[x2][y2]==0&&f==0) //判断能否搜索
{ b[x2][y2]=1; //标记当前位置已走过
kunkun e; e.x=x2; e.y=y2; q.push(e); //将当前下表塞进队列 bfs(x2,y2); //递归继续搜索
} } q.pop(); //队列还原 } }
int main() { for(i=1;i<=14;i++) //二维数组初始化,用于待会用广搜找Helloworld的ascall值
for(j=1;j<=14;j++) { t++; a[i][j]=t; } for(k=0;k<=11;k++) { f=0; for(i=1;i<=14;i++) //用来标记的数组初始化
for(j=1;j<=14;j++) { b[i][j]=0; } bfs(1,1); //开始搜索 }
return 0;
}