Website Summary Files Commits Branches @commit @diff @stats
path: root / Week08 / Exercise13.cpp
blob: 71b530c6ef00dd1349f18896cc3381405d661ad7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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;
}