From e7ff11cbb931574c9f55cde556866e9479bd8774 Mon Sep 17 00:00:00 2001 From: gowthamtupili Date: Sat, 11 Feb 2023 16:39:50 +0530 Subject: [PATCH] Fixed the bugs --- C++/h2.cpp | 6 +++--- C++/m5.cpp | 4 ++-- C++/s1.cpp | 2 +- C++/s4.cpp | 2 +- C++/s5.cpp | 2 +- C++/s6.cpp | 4 ++-- Web-Dev/css-is-awesome/initial.css | 2 +- Web-Dev/event-propogation/initial.js | 2 +- Web-Dev/flex-even-columns/initial.css | 1 + 9 files changed, 13 insertions(+), 12 deletions(-) diff --git a/C++/h2.cpp b/C++/h2.cpp index d29572a..1ade567 100644 --- a/C++/h2.cpp +++ b/C++/h2.cpp @@ -18,16 +18,16 @@ int count(int coins[], int n, int sum) for (i = 1; i < sum + 1; i++) { for (j = 0; j < n; j++) { - x = (i - coins[j] >= 0) ? table[j][i - coins[j]] : 1; + x = (i - coins[j] >= 0) ? table[j][i - coins[j]] : 0; - y = (j > 1) ? table[j - 1][i] : 1; + y = (j > 1) ? table[j - 1][i] : 0; table[i][j] = x + y; } } - return table[sum-1][n - 1]; + return table[sum][n - 1]; } // Driver Code diff --git a/C++/m5.cpp b/C++/m5.cpp index 39456b1..ecade9c 100644 --- a/C++/m5.cpp +++ b/C++/m5.cpp @@ -29,13 +29,13 @@ vector spiralOrder(vector >& matrix) int newX = x + dr[di]; int newY = y + dc[di]; - if (0 <= newX || newX < m && 0 <= newY || newY < n + if (0 <= newX && newX < m && 0 <= newY && newY < n && !seen[newX][newY]) { x = newX; y = newY; } else { - di = (di + 1) / 4; + di = (di + 1) % 4; x += dr[di]; y += dc[di]; } diff --git a/C++/s1.cpp b/C++/s1.cpp index 95629da..2e0b066 100644 --- a/C++/s1.cpp +++ b/C++/s1.cpp @@ -6,7 +6,7 @@ using namespace std; int reverse(int x) { long r=0; while(x){ - r=r*10+x/10; + r=r*10+x%10; x=x/10; } return r; diff --git a/C++/s4.cpp b/C++/s4.cpp index 727e620..5915ad1 100644 --- a/C++/s4.cpp +++ b/C++/s4.cpp @@ -6,7 +6,7 @@ using namespace std; #define Random(n) random()%n -int random(){ +long int random(){ srand(time(0)); return rand(); } diff --git a/C++/s5.cpp b/C++/s5.cpp index 3c05697..d0d70e2 100644 --- a/C++/s5.cpp +++ b/C++/s5.cpp @@ -6,7 +6,7 @@ int main(void){ string string1 = "Hello"; string string2 = "Horld"; - if (string1 == string2) + if (string1.compare(string2)) cout << "Equal"; else cout << "Not Equal"; diff --git a/C++/s6.cpp b/C++/s6.cpp index 736760a..bf54de6 100644 --- a/C++/s6.cpp +++ b/C++/s6.cpp @@ -4,7 +4,7 @@ using namespace std; int maxSubArraySum(int a[], int size) { - int max_so_far = INT_MIN, max_ending_here; + int max_so_far = INT_MIN, max_ending_here = 0; for (int i = 0; i < size; i++) { max_ending_here = max_ending_here + a[i]; @@ -12,7 +12,7 @@ int maxSubArraySum(int a[], int size) max_so_far = max_ending_here; if (max_ending_here < 0) - max_ending_here = max_so_far; + max_ending_here = 0; } return max_so_far; } diff --git a/Web-Dev/css-is-awesome/initial.css b/Web-Dev/css-is-awesome/initial.css index 3bf343a..2e5aee4 100644 --- a/Web-Dev/css-is-awesome/initial.css +++ b/Web-Dev/css-is-awesome/initial.css @@ -7,7 +7,7 @@ body { .container { background: white; - width: 120px; + width: fit-content; height: 200px; padding-inline: 0.3rem; font-size: 3rem; diff --git a/Web-Dev/event-propogation/initial.js b/Web-Dev/event-propogation/initial.js index 71d2c11..319bd68 100644 --- a/Web-Dev/event-propogation/initial.js +++ b/Web-Dev/event-propogation/initial.js @@ -6,7 +6,7 @@ document.getElementById("form").addEventListener("submit", function () { // Event listener for sign-in button document .getElementById("signin-button") - .addEventListener("click", function (event) { + .addEventListener("onClick", function (event) { event.preventDefault(); console.log(userName, password); }); diff --git a/Web-Dev/flex-even-columns/initial.css b/Web-Dev/flex-even-columns/initial.css index 2e6d07a..d0c9737 100644 --- a/Web-Dev/flex-even-columns/initial.css +++ b/Web-Dev/flex-even-columns/initial.css @@ -31,6 +31,7 @@ section>p { .flex-even-columns { display: flex; gap: 2rem; + justify-content: space-between; } .flex-even-columns>* {