Website Summary Files Commits Branches @commit @diff @stats
diff options
context:
space:
mode:
1 files changed, 8 insertions, 8 deletions
-rw-r--r--Sem. 03/Solutions/13. Dumbbell.cpp16
diff --git a/Sem. 03/Solutions/13. Dumbbell.cpp b/Sem. 03/Solutions/13. Dumbbell.cpp
index bc0aad5..7db650a 100644
--- a/Sem. 03/Solutions/13. Dumbbell.cpp
+++ b/Sem. 03/Solutions/13. Dumbbell.cpp
@@ -7,19 +7,19 @@ int main()
int n;
cin >> n;
- int rowWidth = 5 * n / 2;
- int evenness = 1 - n % 2;
- for (int i = 0; i < n; i++)
+ int rowWidth = 3 * n - 2;
+
+ for (int row = 0; row < n; row++)
{
- if (i == 0 || i == n - 1)
+ if (row == 0 || row == n - 1)
{
- for (int j = 0; j < rowWidth; j++)
- cout << ((j == n || j == n + evenness) ? " " : ".");
+ for (int col = 0; col < rowWidth; col++)
+ cout << ((col >= n && col <= rowWidth - n - 1) ? " " : ".");
}
else
{
- for (int j = 0; j < rowWidth; j++)
- cout << ((j == 1 || j == 1 + evenness || j == rowWidth - 2 || j == rowWidth - 2 - evenness) ? " " : ".");
+ for (int col = 0; col < rowWidth; col++)
+ cout << (((col >= 1 && col <= n - 2) || (col >= rowWidth - n + 1 && col <= rowWidth - 2)) ? " " : ".");
}
cout << endl;
}