From 5bac9d08b1e583d3053148512443c845f644d72c Mon Sep 17 00:00:00 2001 From: Syndamia Date: Fri, 29 Oct 2021 09:29:40 +0300 Subject: Added missing spaces between keyword and bracket. Added newlines for improved readability. --- Sem. 03/Solutions/05. Power_Of_Two.cpp | 2 +- Sem. 03/Solutions/06. Polynomial_Solutions.cpp | 5 +++-- Sem. 03/Solutions/08. Triangle.cpp | 5 +++-- Sem. 03/Solutions/09. Lefthand_Triangle.cpp | 6 +++--- Sem. 03/Solutions/10. Spiral_Numbers.cpp | 4 ++-- Sem. 03/Solutions/12. Frame.cpp | 4 +++- Sem. 03/Solutions/13. Dumbbell.cpp | 6 +++--- Sem. 03/Solutions/14. Tree.cpp | 10 ++++++---- 8 files changed, 24 insertions(+), 18 deletions(-) diff --git a/Sem. 03/Solutions/05. Power_Of_Two.cpp b/Sem. 03/Solutions/05. Power_Of_Two.cpp index 9cbe442..0a5c88f 100644 --- a/Sem. 03/Solutions/05. Power_Of_Two.cpp +++ b/Sem. 03/Solutions/05. Power_Of_Two.cpp @@ -7,7 +7,7 @@ int main() int n; cin >> n; - while(n % 2 == 0 && n > 1) + while (n % 2 == 0 && n > 1) n /= 2; cout << ((n == 1) ? "true" : "false") << endl; diff --git a/Sem. 03/Solutions/06. Polynomial_Solutions.cpp b/Sem. 03/Solutions/06. Polynomial_Solutions.cpp index 375f6ec..ba34792 100644 --- a/Sem. 03/Solutions/06. Polynomial_Solutions.cpp +++ b/Sem. 03/Solutions/06. Polynomial_Solutions.cpp @@ -8,9 +8,10 @@ int main() cin >> a >> b >> c >> d >> e; double fx; - for (int x = -100; x <= 100; x++) { + for (int x = -100; x <= 100; x++) + { fx = a * x*x*x*x + b * x*x*x + c * x*x + d * x + e; - if(fx >= 0) + if (fx >= 0) cout << x << " "; } cout << endl; diff --git a/Sem. 03/Solutions/08. Triangle.cpp b/Sem. 03/Solutions/08. Triangle.cpp index 72fec46..ca25b0e 100644 --- a/Sem. 03/Solutions/08. Triangle.cpp +++ b/Sem. 03/Solutions/08. Triangle.cpp @@ -7,10 +7,11 @@ int main() int n; cin >> n; - for(int i = 1; i <= n; i++) + for (int i = 1; i <= n; i++) { - for(int j = 0; j < i; j++) + for (int j = 0; j < i; j++) cout << "$ "; + cout << endl; } } diff --git a/Sem. 03/Solutions/09. Lefthand_Triangle.cpp b/Sem. 03/Solutions/09. Lefthand_Triangle.cpp index 4d6e9b7..183aea8 100644 --- a/Sem. 03/Solutions/09. Lefthand_Triangle.cpp +++ b/Sem. 03/Solutions/09. Lefthand_Triangle.cpp @@ -7,14 +7,14 @@ int main() int n; cin >> n; - for(int i = -n + 1; i < n; i++) + for (int i = -n + 1; i < n; i++) { int absI = ((i > 0) ? i : -i), number = 0; - for(int j = n - absI; j > 0; j--) + for (int j = n - absI; j > 0; j--) (number *= 10) += j; - for(int j = absI; j > 0; j--) + for (int j = absI; j > 0; j--) cout << " "; cout << number << endl; diff --git a/Sem. 03/Solutions/10. Spiral_Numbers.cpp b/Sem. 03/Solutions/10. Spiral_Numbers.cpp index 0b9d2a9..d5579af 100644 --- a/Sem. 03/Solutions/10. Spiral_Numbers.cpp +++ b/Sem. 03/Solutions/10. Spiral_Numbers.cpp @@ -7,10 +7,10 @@ int main() int n; cin >> n; - for(int i = 0; i < n; i++) + for (int i = 0; i < n; i++) { int previous = i + 1; - for(int j = 0; j < n; j++) + for (int j = 0; j < n; j++) { if (j == 0) cout << previous << " "; diff --git a/Sem. 03/Solutions/12. Frame.cpp b/Sem. 03/Solutions/12. Frame.cpp index 3d19376..48ae946 100644 --- a/Sem. 03/Solutions/12. Frame.cpp +++ b/Sem. 03/Solutions/12. Frame.cpp @@ -7,10 +7,12 @@ int main() int n; cin >> n; - for(int i = 0; i < n; i++) + for (int i = 0; i < n; i++) { cout << ((i == 0 || i == n-1) ? "+" : "|"); for(int j = 0; j < n - 2; j++) + + for (int j = 0; j < n - 2; j++) cout << "-"; cout << ((i == 0 || i == n-1) ? "+" : "|") << endl; } diff --git a/Sem. 03/Solutions/13. Dumbbell.cpp b/Sem. 03/Solutions/13. Dumbbell.cpp index d59cfac..bc0aad5 100644 --- a/Sem. 03/Solutions/13. Dumbbell.cpp +++ b/Sem. 03/Solutions/13. Dumbbell.cpp @@ -9,16 +9,16 @@ int main() int rowWidth = 5 * n / 2; int evenness = 1 - n % 2; - for(int i = 0; i < n; i++) + for (int i = 0; i < n; i++) { if (i == 0 || i == n - 1) { - for(int j = 0; j < rowWidth; j++) + for (int j = 0; j < rowWidth; j++) cout << ((j == n || j == n + evenness) ? " " : "."); } else { - for(int j = 0; j < rowWidth; j++) + for (int j = 0; j < rowWidth; j++) cout << ((j == 1 || j == 1 + evenness || j == rowWidth - 2 || j == rowWidth - 2 - evenness) ? " " : "."); } cout << endl; diff --git a/Sem. 03/Solutions/14. Tree.cpp b/Sem. 03/Solutions/14. Tree.cpp index 411db7f..c6ee5cd 100644 --- a/Sem. 03/Solutions/14. Tree.cpp +++ b/Sem. 03/Solutions/14. Tree.cpp @@ -7,19 +7,21 @@ int main() int n; cin >> n; - for(int i = 1; i <= n; i++) + for (int i = 1; i <= n; i++) { - for(int j = n - i; j > 0; j--) + for (int j = n - i; j > 0; j--) cout << " "; - for(int j = -i + 1; j < i; j++) + + for (int j = -i + 1; j < i; j++) cout << i - ((j < 0) ? -j : j); cout << endl; } - for(int i = n - 1; i > 0; i--) + for (int i = n - 1; i > 0; i--) { for (int j = n - 1; j > 0; j--) cout << " "; + cout << i << endl; } } -- cgit v1.3.1-23-gd82d