Lang:G++
Edit12345678910111213141516171819202122232425262728293031#include <iostream>#include <cstring>#include <queue>using namespace std;struct myNode{int x;int y;myNode(int valx, int valy): x(valx), y(valy) {}};void bfs(int f[][8], int x, int y){for(int i = 0; i < 8; i++)for(int j = 0; j < 8; j++)f[i][j] = -1;int nowx, nowy;f[x][y] = 0;queue<myNode*> q;myNode* m = new myNode(x, y);q.push(m);while(!q.empty()){m = q.front();q.pop();x = m->x;y = m->y;int xi[8] = {-2, -2, -1, -1, 1, 1, 2, 2};int yi[8] = {1, -1, 2, -2, 2, -2, 1, -1};for(int i = 0; i < 8; i++) {nowx = x + xi[i];