【宽搜入门】8数码难题
题目描述
初始状态的步数就算1,哈哈
输入:第一个3*3的矩阵是原始状态,第二个3*3的矩阵是目标状态。
输出:移动所用最少的步数
input
2 8 3
1 6 4
7 0 5
1 2 3
8 0 4
7 6 5
output
6
Code
#include<iostream>
#include<queue>
using namespace std;
struct node{
int x, y;
int step;
int M[3][3];
int last[2];
} Node;
int X[4] = {
0, 0, 1, -1};
int Y[4] = {
1, -1,

最低0.47元/天 解锁文章
448





