From 716b3ef8850f210feac3a173597d2e6fd8743f7f Mon Sep 17 00:00:00 2001 From: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Date: Wed, 13 Oct 2021 09:26:57 +0000 Subject: [PATCH 1/3] clang-format and clang-tidy fixes for b40a2801 --- cpu_scheduling_algorithms/fcfs_scheduling.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/cpu_scheduling_algorithms/fcfs_scheduling.cpp b/cpu_scheduling_algorithms/fcfs_scheduling.cpp index b78bbe055..0da9e0165 100644 --- a/cpu_scheduling_algorithms/fcfs_scheduling.cpp +++ b/cpu_scheduling_algorithms/fcfs_scheduling.cpp @@ -9,15 +9,15 @@ * @author Pratyush Vatsa(https://github.com/Pratyush219) */ -#include /// for IO operations -#include /// for std::priority_queue -#include /// for std::unordered_set -#include /// for std::vector #include /// for sorting #include /// for assert #include /// random number generation #include /// for time #include /// for formatting the output +#include /// for IO operations +#include /// for std::priority_queue +#include /// for std::unordered_set +#include /// for std::vector using std::cin; using std::cout; @@ -268,7 +268,8 @@ void test() { readyQueue.addProcess(get<0>(input[i]), get<1>(input[i]), get<2>(input[i])); } - vector> res = get_final_status(input); + vector> + res = get_final_status(input); assert(res == readyQueue.scheduleForFcfs()); // readyQueue.printResult(); } From 89bfc1244e658ebe4e1b09ba6800815b4f103f36 Mon Sep 17 00:00:00 2001 From: Harsh Tripathi <63543719+happy-t@users.noreply.github.com> Date: Wed, 13 Oct 2021 09:19:09 -0700 Subject: [PATCH 2/3] fix: Armstrong number bug fixes (#1689) * added a new directory named Recursion and a most common exxample of recusion i.e. Tower of Hanoi in it * Added Comments * Bug fixed according to the correct definition of armstrong_number * Bug Fixed in armstrong_number.cpp Bug Fixed in armstrong_number.cpp according to the correct definition of armstrong_number. * Update armstrong_number.cpp * Added documentation * Delete Recursion directory * Update armstrong_number.cpp * Update dynamic_programming/armstrong_number.cpp Co-authored-by: David Leal * Update armstrong_number.cpp fixed errors. * Apply suggestions from code review * Apply suggestions from code review * Apply suggestions from code review * Apply suggestions from code review * Apply suggestions from code review * Apply suggestions from code review * Update armstrong_number.cpp Applied suggested changes. * Update armstrong_number.cpp Co-authored-by: David Leal --- dynamic_programming/armstrong_number.cpp | 44 +++++++++++++++++------- 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/dynamic_programming/armstrong_number.cpp b/dynamic_programming/armstrong_number.cpp index 270a705f7..ba8f054dd 100644 --- a/dynamic_programming/armstrong_number.cpp +++ b/dynamic_programming/armstrong_number.cpp @@ -1,21 +1,41 @@ // Program to check whether a number is an armstrong number or not #include - +#include using std::cin; using std::cout; int main() { - int n, k, d, s = 0; - cout << "Enter a number:"; + int n = 0, temp = 0, rem = 0, count = 0, sum = 0; + cout << "Enter a number: "; cin >> n; - k = n; - while (k != 0) { - d = k % 10; - s += d * d * d; - k /= 10; + + temp = n; + + /* First Count the number of digits + in the given number */ + while(temp != 0) { + temp /= 10; + count++; } - if (s == n) - cout << n << "is an armstrong number"; - else - cout << n << "is not an armstrong number"; + + /* Calaculation for checking of armstrongs number i.e. + in a n digit number sum of the digits raised to a power of n + is equal to the original number */ + + temp = n; + while(temp!=0) { + rem = temp%10; + sum += (int) pow(rem,count); + temp/=10; + } + + + if (sum == n) { + cout << n << " is an armstrong number"; + } + else { + cout << n << " is not an armstrong number"; + } + + return 0; } From 160b82e9e08d42073dd8e75b83ff7e571b9cc5c9 Mon Sep 17 00:00:00 2001 From: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Date: Wed, 13 Oct 2021 16:45:16 +0000 Subject: [PATCH 3/3] clang-format and clang-tidy fixes for 243dcc15 --- dynamic_programming/armstrong_number.cpp | 26 +++++++++++------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/dynamic_programming/armstrong_number.cpp b/dynamic_programming/armstrong_number.cpp index ba8f054dd..53f1be9fe 100644 --- a/dynamic_programming/armstrong_number.cpp +++ b/dynamic_programming/armstrong_number.cpp @@ -1,6 +1,6 @@ // Program to check whether a number is an armstrong number or not -#include #include +#include using std::cin; using std::cout; @@ -8,34 +8,32 @@ int main() { int n = 0, temp = 0, rem = 0, count = 0, sum = 0; cout << "Enter a number: "; cin >> n; - + temp = n; - + /* First Count the number of digits in the given number */ - while(temp != 0) { + while (temp != 0) { temp /= 10; count++; } - /* Calaculation for checking of armstrongs number i.e. + /* Calaculation for checking of armstrongs number i.e. in a n digit number sum of the digits raised to a power of n is equal to the original number */ - + temp = n; - while(temp!=0) { - rem = temp%10; - sum += (int) pow(rem,count); - temp/=10; + while (temp != 0) { + rem = temp % 10; + sum += static_cast(pow(rem, count)); + temp /= 10; } - if (sum == n) { cout << n << " is an armstrong number"; - } - else { + } else { cout << n << " is not an armstrong number"; } - + return 0; }