Website Summary Files Commits Branches @commit @diff @stats
path: root / Sem. 03 / Solutions / 13. Dumbbell.cpp
blob: e0afd63633267f416c614dcd528bdda750ed2aab (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
#include <iostream>

using namespace std;

int main()
{
	int n;
	cin >> n;

	int rowWidth = 3 * n - 2;

	for (int row = 0; row < n; row++)
	{
		if (row == 0 || row == n - 1)
		{
			for (int col = 0; col < rowWidth; col++)
				cout << ((col >= n && col <= rowWidth - n - 1) ? " " : "."); // Print spaces in the middle
		}
		else
		{
			for (int col = 0; col < rowWidth; col++)
			{
				bool inLeftHole = (col >= 1 && col <= n - 2);
				bool inRightHole = (col >= rowWidth - n + 1 && col <= rowWidth - 2);
				cout << ((inLeftHole || inRightHole) ? " " : ".");
			}
		}
		cout << endl;
	}
}