Website Summary Files Commits Branches @commit @diff @stats
diff options
context:
space:
mode:
Commit32ddae76a51ced3f3a134c5373ed4ce19024e52a (patch)
Author
 Syndamia <kamen.d.mladenov@protonmail.com>
2021-10-29 10:00:17 +0300
Committer
 Syndamia <kamen.d.mladenov@protonmail.com>
2021-10-29 10:17:09 +0300
Filesf5c4a9155f44eab56f2953db440786ee7c2dd078
Introduction_to_programming_FMI-32ddae76a51ced3f3a134c5373ed4ce19024e52a.tar
Introduction_to_programming_FMI-32ddae76a51ced3f3a134c5373ed4ce19024e52a.tar.gz
Introduction_to_programming_FMI-32ddae76a51ced3f3a134c5373ed4ce19024e52a.zip
Parent95f035215e507305ab5fcd0613327f8845c55c87 (diff)
Fixed math of solution to exercise 13
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;
}