Website Summary Files Commits Branches @commit @diff @stats
path: root / Week08 / Exercise13.cpp
diff options
context:
space:
mode:
Commit5294e73a21f3402e14fcf3379c721275e2dd19c2 (patch)
Author
 Syndamia <kamen@syndamia.com>
2025-11-23 15:25:29 +0200
Committer
 Syndamia <kamen@syndamia.com>
2025-11-23 16:05:21 +0200
Files3f02cc12e0868ac043d7f937fec380b29f54c71a /Week08/Exercise13.cpp
upp-2025-solutions-5294e73a21f3402e14fcf3379c721275e2dd19c2.tar
upp-2025-solutions-5294e73a21f3402e14fcf3379c721275e2dd19c2.tar.gz
upp-2025-solutions-5294e73a21f3402e14fcf3379c721275e2dd19c2.zip
Parent3e8ac7ba4a8f410703aa5a8426f542217adcbf2f (diff)
feat(Week08): Add solutions
1 files changed, 31 insertions, 0 deletions
-rw-r--r--Week08/Exercise13.cpp31
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 <iostream>
+
+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;
+}