From bc6fa2f8d7967acd859c0f660cad81199e53b0fb Mon Sep 17 00:00:00 2001 From: Andrew Guschin Date: Thu, 19 May 2022 14:12:12 +0400 Subject: =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=BE=D1=82=D1=87=D1=91=D1=82=D0=BE=D0=B2=20=D0=BF?= =?UTF-8?q?=D0=BE=20=D0=BF=D0=B5=D1=80=D0=B2=D1=8B=D0=BC=20=D1=82=D1=80?= =?UTF-8?q?=D1=91=D0=BC=20=D0=BB=D0=B0=D0=B1=D0=B0=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- knights-tour.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'knights-tour.cpp') 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 v; std::vector 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)) { -- cgit v1.2.3