summaryrefslogtreecommitdiff
path: root/knights-tour.cpp
diff options
context:
space:
mode:
authorAndrew Guschin <guschin.drew@gmail.com>2022-05-19 14:12:12 +0400
committerAndrew Guschin <guschin.drew@gmail.com>2022-05-19 14:12:12 +0400
commitbc6fa2f8d7967acd859c0f660cad81199e53b0fb (patch)
tree1cc2c59f70ed45073500e705cdd1dd8925450132 /knights-tour.cpp
parentda81a8f76f56a6b21dda16c8df5f1df5f9b962a3 (diff)
Добавление отчётов по первым трём лабам
Diffstat (limited to 'knights-tour.cpp')
-rw-r--r--knights-tour.cpp17
1 files changed, 6 insertions, 11 deletions
diff --git a/knights-tour.cpp b/knights-tour.cpp
index 3f1e674..d0f9a3a 100644
--- a/knights-tour.cpp
+++ b/knights-tour.cpp
@@ -14,20 +14,15 @@ neighbors(int row, int col)
{
std::vector<point_t> v;
std::vector<point_t> possible = {
- { row - 2, col - 1 },
- { row - 1, col - 2 },
- { row + 1, col - 2 },
- { row + 2, col - 1 },
- { row - 2, col + 1 },
- { row - 1, col + 2 },
- { row + 1, col + 2 },
- { row + 2, col + 1 },
+ { row - 2, col - 1 }, { row - 1, col - 2 },
+ { row + 1, col - 2 }, { row + 2, col - 1 },
+ { row - 2, col + 1 }, { row - 1, col + 2 },
+ { row + 1, col + 2 }, { row + 2, col + 1 },
};
for (point_t p : possible)
{
- if (p.row >= 0 && p.row < n &&
- p.col >= 0 && p.col < n)
+ if (p.row >= 0 && p.row < n && p.col >= 0 && p.col < n)
{
v.push_back(p);
}
@@ -37,7 +32,7 @@ neighbors(int row, int col)
}
bool
-tour(int row, int col, int step, field_t field, field_t &result)
+tour(int row, int col, int step, field_t &field, field_t &result)
{
for (point_t p : neighbors(row, col))
{