diff --git a/job_sequencing.cpp b/job_sequencing.cpp new file mode 100644 index 00000000..ead9e536 --- /dev/null +++ b/job_sequencing.cpp @@ -0,0 +1,52 @@ +#include +#include +using namespace std; + +struct Job +{ + char id; + int dead; + int profit; +}; + +bool comparison(Job a, Job b) +{ + return (a.profit > b.profit); +} +void printJobScheduling(Job arr[], int n) +{ + sort(arr, arr+n, comparison); + + int result[n]; + bool slot[n]; + for (int i=0; i=0; j--) + { + + if (slot[j]==false) + { + result[j] = i; + slot[j] = true; + break; + } + } + } + + for (int i=0; i