马踏棋盘贪心优化非递归走全部路
先给上代码
#include<iostream>
#include<stack>
#include<cstring>
#include<ctime>
#include<iomanip>
#include<algorithm>
using namespace std;
struct PosType
{
int y;
int x;
PosType &operator+=(const PosType& t)
{
y+=t.y;
x+=t.x;
return *this;
}
PosType operator+(const PosType& t)
{
PosType temp;
temp=*this;
temp+=t;
return temp;
}
};
struct DataType
{
PosType seat;
int di;
int next[8];
};
int m_board[8][8];
PosType direct[8] = {
{
-1,-2},{
-1,2},{
-2,-1},{
-2,1},{
1,2},{
1,-2},{
2,1},{
2,-1}};
int n=0;
bool limit(const PosType &t)
{
return t.