Website Summary Files Commits Branches @commit @diff @stats
diff options
context:
space:
mode:
Commit2b75c583cc64bdc16f619e9de7c4352121e069df (patch)
Author
 Syndamia <kamen.d.mladenov@protonmail.com>
2021-11-03 17:23:02 +0200
Committer
 Syndamia <kamen.d.mladenov@protonmail.com>
2021-11-03 17:23:02 +0200
Files0ba5f203e136a2a90450c317060e526268616887
Introduction_to_programming_FMI-2b75c583cc64bdc16f619e9de7c4352121e069df.tar
Introduction_to_programming_FMI-2b75c583cc64bdc16f619e9de7c4352121e069df.tar.gz
Introduction_to_programming_FMI-2b75c583cc64bdc16f619e9de7c4352121e069df.zip
Parentd376ddb1ada7de6a2faa3e1e53b38fe5aa5c03dc (diff)
Solved newly added exercise 15
1 files changed, 34 insertions, 0 deletions
-rw-r--r--Sem. 03/Solutions/15. Bowtie.cpp34
diff --git a/Sem. 03/Solutions/15. Bowtie.cpp b/Sem. 03/Solutions/15. Bowtie.cpp
new file mode 100644
index 0000000..e06ab7e
--- /dev/null
+++ b/Sem. 03/Solutions/15. Bowtie.cpp
@@ -0,0 +1,34 @@
+#include <iostream>
+
+using namespace std;
+
+int main() {
+ int n;
+ cin >> n;
+
+ char middleSpacer = ' ';
+ for(int i = -n + 1; i < n; i++)
+ {
+ int absI = (i < 0) ? -i : i, diff = n - absI;
+
+ /* Numbers on the left */
+ for(int j = 1; j <= diff; j++)
+ cout << j << " ";
+
+ /* Spaces/Line in the middle */
+ if (i == 0)
+ middleSpacer = '-';
+
+ for(int j = 5 * n - 4 * diff; j > 0; j--)
+ cout << middleSpacer;
+
+ if (i == 0)
+ middleSpacer = ' ';
+
+ /* Number on the right */
+ for(int j = diff; j > 0; j--)
+ cout << " " << j;
+
+ cout << endl;
+ }
+}