八数码问题 紫书上的简单搜索 渣渣好久才弄懂 #include<cstdio> #include<cstring> using namespace std; const int M = 1000003; int x[4] = { -1, 1, 0, 0}, y[4] = {0, 0, -1, 1}; int dis[M], h[M], s[M][9], e[9]; int aton(int a[]) { int t = 0; for(int i = 0; i < 9; +…
Bfs搜索 1.把棋盘直接作为状态: #include<iostream> #include<cstring> #include<queue> #include<cstdlib> using namespace std; ; ; int flag; struct Point{ int x,y; }; struct Node{ int board[Size][Size]; Point space; int step; }; , ,,,,,,,,}; ]={-,…