From 5294e73a21f3402e14fcf3379c721275e2dd19c2 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sun, 23 Nov 2025 15:25:29 +0200 Subject: feat(Week08): Add solutions --- Week08/Exercise13.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 Week08/Exercise13.cpp (limited to 'Week08/Exercise13.cpp') diff --git a/Week08/Exercise13.cpp b/Week08/Exercise13.cpp new file mode 100644 index 0000000..71b530c --- /dev/null +++ b/Week08/Exercise13.cpp @@ -0,0 +1,31 @@ +#include + +int main() { + const unsigned int SIZE = 8; + char mat[SIZE][SIZE]; + + for (unsigned int i = 0; i < SIZE; i++) + for (unsigned int j = 0; j < SIZE; j++) + std::cin >> mat[i][j]; + + int minRow = SIZE, maxRow = 0, minCol = SIZE, maxCol = 0; + for (unsigned int i = 0; i < SIZE; i++) { + for (unsigned int j = 0; j < SIZE; j++) { + if (mat[i][j] == '+') { + if (i < minCol) minCol = i; + if (i > maxCol) maxCol = i; + if (j < minRow) minRow = j; + if (j > maxRow) maxRow = j; + } + } + } + + if (minRow == SIZE) { + minRow = 1; + minCol = 1; + } + + std::cout << (maxCol - minCol + 1) << ' ' << (maxRow - minRow + 1) << std::endl; + + return 0; +} -- cgit v1.3.1-23-gd82d