diff options
Updated some styling and formatting
1 files changed, 10 insertions, 7 deletions
| -rw-r--r-- | Year 1/Programming introduction/Solutions Sem. 03/15. Bowtie.cpp | 17 |
diff --git a/Year 1/Programming introduction/Solutions Sem. 03/15. Bowtie.cpp b/Year 1/Programming introduction/Solutions Sem. 03/15. Bowtie.cpp index e06ab7e..61c5df3 100644 --- a/Year 1/Programming introduction/Solutions Sem. 03/15. Bowtie.cpp +++ b/Year 1/Programming introduction/Solutions Sem. 03/15. Bowtie.cpp @@ -7,26 +7,29 @@ int main() { cin >> n; char middleSpacer = ' '; - for(int i = -n + 1; i < n; i++) + 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++) + // Numbers on the left + + for (int j = 1; j <= diff; j++) cout << j << " "; - /* Spaces/Line in the middle */ + // Spaces/Line in the middle + if (i == 0) middleSpacer = '-'; - for(int j = 5 * n - 4 * diff; j > 0; j--) + 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--) + // Number on the right + + for (int j = diff; j > 0; j--) cout << " " << j; cout << endl; |
