mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-02-03 10:35:34 +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)
|
||||
*/
|
||||
|
||||
#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 <cassert> /// for assert
|
||||
#include <cstdlib> /// random number generation
|
||||
#include <ctime> /// for time
|
||||
#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::cout;
|
||||
@@ -271,7 +271,8 @@ void test() {
|
||||
readyQueue.addProcess(get<0>(input[i]), get<1>(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());
|
||||
// readyQueue.printResult();
|
||||
}
|
||||
|
||||
@@ -1,21 +1,39 @@
|
||||
// Program to check whether a number is an armstrong number or not
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
|
||||
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 += 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