Summary Files Commits Branches @commit @diff @stats
path: root / Year 1 / Programming introduction / Solutions Sem. 03 / 10. Spiral_Numbers.cpp
diff options
context:
space:
mode:
1 files changed, 3 insertions, 1 deletions
-rw-r--r--Year 1/Programming introduction/Solutions Sem. 03/10. Spiral_Numbers.cpp4
diff --git a/Year 1/Programming introduction/Solutions Sem. 03/10. Spiral_Numbers.cpp b/Year 1/Programming introduction/Solutions Sem. 03/10. Spiral_Numbers.cpp
index 66e5e70..15ab136 100644
--- a/Year 1/Programming introduction/Solutions Sem. 03/10. Spiral_Numbers.cpp
+++ b/Year 1/Programming introduction/Solutions Sem. 03/10. Spiral_Numbers.cpp
@@ -10,6 +10,7 @@ int main()
for (int row = 0; row < n; row++)
{
int previous = row + 1;
+
for (int col = 0; col < n; col++)
{
if (col == 0)
@@ -17,8 +18,9 @@ int main()
else if (col % 2 == 0)
cout << (previous += row * 2 + 1) << " ";
else
- cout << (previous += (n -row -1) * 2 + 1) << " ";
+ cout << (previous += (n - row - 1) * 2 + 1) << " ";
}
+
cout << endl;
}
}