In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how to use C++ to achieve horse chessboard, the article is very detailed, has a certain reference value, interested friends must finish!
The horse stepped on the chessboard and walked all over the chessboard with one horse. I use a two-dimensional array to record the entire path of the simulation, x as the column, y as the row, to find the next grid clockwise, the algorithm is relatively simple, through recursion and circular backtracking, that is, if it is an array of 8 to 8, the worst possible execution is 8 ^ (xroomy) times, which takes a long time to doubt life.
# include#define X 5#define Y 5 void ShowResult (); using namespace std; int chess [Y] [X] = {0}; int counter=0; int Next (int* x where intt * y case where) {switch (where) {case 0: if (* x+1=0&&chess [* ylashi 2] [* xlue 1] = 0) {* x quoti1; * yLaught 2; return 1 } break; case 1: if (* x+2=0&&chess [* yMurray 1] [* xanth2] = 0) {* xanthium 2; * yMurray 1; return 1;} break Case 2: if (* x+2=0&&chess [* yMurray 2] [* xmur1] = 0) {* xmuri 1; * yMuth2; return 1;} break;} return 0;} int Explore (int x quotation int y) {int x1fux; int y1ray; int flag; int where=0; counter++ Chess [y] [x] = counter; if (counter==X*Y) {return 1;} flag=Next
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.