Website Summary Files Commits Branches @commit @diff @stats
diff options
context:
space:
mode:
Commit95f035215e507305ab5fcd0613327f8845c55c87 (patch)
Author
 Syndamia <kamen.d.mladenov@protonmail.com>
2021-10-29 09:36:49 +0300
Committer
 Syndamia <kamen.d.mladenov@protonmail.com>
2021-10-29 10:17:09 +0300
Files0335c1d26a963c42d30faf9e5c38d5eaa8ed9d1c
Introduction_to_programming_FMI-95f035215e507305ab5fcd0613327f8845c55c87.tar
Introduction_to_programming_FMI-95f035215e507305ab5fcd0613327f8845c55c87.tar.gz
Introduction_to_programming_FMI-95f035215e507305ab5fcd0613327f8845c55c87.zip
Parentd634f3e6087031564cf76a73fc4cf7b08b5b6678 (diff)
Renamed variables and reordered code to improve readability
1 files changed, 7 insertions, 7 deletions
-rw-r--r--Sem. 03/Solutions/10. Spiral_Numbers.cpp14
diff --git a/Sem. 03/Solutions/10. Spiral_Numbers.cpp b/Sem. 03/Solutions/10. Spiral_Numbers.cpp
index d5579af..5a3dced 100644
--- a/Sem. 03/Solutions/10. Spiral_Numbers.cpp
+++ b/Sem. 03/Solutions/10. Spiral_Numbers.cpp
@@ -7,17 +7,17 @@ int main()
int n;
cin >> n;
- for (int i = 0; i < n; i++)
+ for (int row = 0; row < n; row++)
{
- int previous = i + 1;
- for (int j = 0; j < n; j++)
+ int previous = row + 1;
+ for (int col = 0; col < n; col++)
{
- if (j == 0)
+ if (col == 0)
cout << previous << " ";
- else if (j % 2 == 1)
- cout << (previous += (n-i-1) * 2 + 1) << " ";
+ else if (col % 2 == 0)
+ cout << (previous += row*2 + 1) << " ";
else
- cout << (previous += i*2 + 1) << " ";
+ cout << (previous += (n-row-1) * 2 + 1) << " ";
}
cout << endl;
}