Summary Files Commits Branches @commit @diff @stats
path: root / Year 1 / Programming introduction / Solutions Sem. 03 / 13. Dumbbell.cpp
diff options
context:
space:
mode:
1 files changed, 26 insertions, 0 deletions
-rw-r--r--Year 1/Programming introduction/Solutions Sem. 03/13. Dumbbell.cpp26
diff --git a/Year 1/Programming introduction/Solutions Sem. 03/13. Dumbbell.cpp b/Year 1/Programming introduction/Solutions Sem. 03/13. Dumbbell.cpp
new file mode 100644
index 0000000..7db650a
--- /dev/null
+++ b/Year 1/Programming introduction/Solutions Sem. 03/13. Dumbbell.cpp
@@ -0,0 +1,26 @@
+#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) ? " " : ".");
+ }
+ else
+ {
+ for (int col = 0; col < rowWidth; col++)
+ cout << (((col >= 1 && col <= n - 2) || (col >= rowWidth - n + 1 && col <= rowWidth - 2)) ? " " : ".");
+ }
+ cout << endl;
+ }
+}