mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-02-04 02:56:40 +08:00
Merge branch 'scheduling' of https://github.com/Pratyush219/C-Plus-Plus into scheduling
This commit is contained in:
@@ -8,15 +8,15 @@
|
|||||||
* @author [Pratyush Vatsa](https://github.com/Pratyush219)
|
* @author [Pratyush Vatsa](https://github.com/Pratyush219)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <iostream> /// for IO operations
|
|
||||||
#include <queue> /// for std::priority_queue
|
|
||||||
#include <unordered_set> /// for std::unordered_set
|
|
||||||
#include <vector> /// for std::vector
|
|
||||||
#include <algorithm> /// for sorting
|
#include <algorithm> /// for sorting
|
||||||
#include <cassert> /// for assert
|
#include <cassert> /// for assert
|
||||||
#include <cstdlib> /// random number generation
|
#include <cstdlib> /// random number generation
|
||||||
#include <ctime> /// for time
|
#include <ctime> /// for time
|
||||||
#include <iomanip> /// for formatting the output
|
#include <iomanip> /// for formatting the output
|
||||||
|
#include <iostream> /// for IO operations
|
||||||
|
#include <queue> /// for std::priority_queue
|
||||||
|
#include <unordered_set> /// for std::unordered_set
|
||||||
|
#include <vector> /// for std::vector
|
||||||
|
|
||||||
using std::cin;
|
using std::cin;
|
||||||
using std::cout;
|
using std::cout;
|
||||||
@@ -271,7 +271,8 @@ void test() {
|
|||||||
readyQueue.addProcess(get<0>(input[i]), get<1>(input[i]),
|
readyQueue.addProcess(get<0>(input[i]), get<1>(input[i]),
|
||||||
get<2>(input[i]));
|
get<2>(input[i]));
|
||||||
}
|
}
|
||||||
vector<tuple<uint32_t, uint32_t, uint32_t, double, double, double>> res = get_final_status<uint32_t, uint32_t, uint32_t>(input);
|
vector<tuple<uint32_t, uint32_t, uint32_t, double, double, double>>
|
||||||
|
res = get_final_status<uint32_t, uint32_t, uint32_t>(input);
|
||||||
assert(res == readyQueue.scheduleForFcfs());
|
assert(res == readyQueue.scheduleForFcfs());
|
||||||
// readyQueue.printResult();
|
// readyQueue.printResult();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +1,39 @@
|
|||||||
// Program to check whether a number is an armstrong number or not
|
// Program to check whether a number is an armstrong number or not
|
||||||
|
#include <cmath>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
using std::cin;
|
using std::cin;
|
||||||
using std::cout;
|
using std::cout;
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
int n, k, d, s = 0;
|
int n = 0, temp = 0, rem = 0, count = 0, sum = 0;
|
||||||
cout << "Enter a number:";
|
cout << "Enter a number: ";
|
||||||
cin >> n;
|
cin >> n;
|
||||||
k = n;
|
|
||||||
while (k != 0) {
|
temp = n;
|
||||||
d = k % 10;
|
|
||||||
s += d * d * d;
|
/* First Count the number of digits
|
||||||
k /= 10;
|
in the given number */
|
||||||
|
while (temp != 0) {
|
||||||
|
temp /= 10;
|
||||||
|
count++;
|
||||||
}
|
}
|
||||||
if (s == n)
|
|
||||||
cout << n << "is an armstrong number";
|
/* Calaculation for checking of armstrongs number i.e.
|
||||||
else
|
in a n digit number sum of the digits raised to a power of n
|
||||||
cout << n << "is not an armstrong number";
|
is equal to the original number */
|
||||||
|
|
||||||
|
temp = n;
|
||||||
|
while (temp != 0) {
|
||||||
|
rem = temp % 10;
|
||||||
|
sum += static_cast<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;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user