greedy algorithms use in schedule processses

i need to write a program using greedy algorithm strategy to determine time sensitive processes.

i found some code online that seems useful but it doesnt add up completely.

header file:
#pragma once

class Process
{
private:
float duration, startTime, endRequiredTime;
public:
Process();
~Process();
void setduration(float);
float getduration();
void setstartTime(float);
float getstartTime();
void setendRequiredTime(float);
float getendRequiredTime();
void scheduleProcesses();
};

.cpp file:
#include "Process.h"
#include <iostream>
#include <vector>

using namespace std;

Process::Process()
{

}

Process::~Process()
{
}

void Process::setendRequiredTime(float ert)
{
endRequiredTime = ert;
}
float Process::getendRequiredTime()
{
return endRequiredTime;
}
void Process::setduration(float d)
{
duration = d;
}
float Process::getduration()
{
return duration;
}
void Process::setstartTime(float st)
{
startTime = st;
}
float Process::getstartTime()
{
return startTime;
}

and the main:
#include "Process.h"
#include <iostream>
#include <vector>

using namespace std;

int main()
{

std::vector<Process> processes;

Process p1(5,11);
Process p2(5,5);
Process p3(7,15);
Process p4(6,19);
Process p5(8,9);

processes.push_back(p1);
processes.push_back(p2);
processes.push_back(p3);
processes.push_back(p4);
processes.push_back(p5);

vector<Process> scheduled = scheduleProcesses(processes);
for (unsigned int i = 0; i < scheduled.size(); i++) {
cout << scheduled[i].getStartTime() << " - ";
cout << (scheduled[i].getStartTime() + scheduled[i].getDuration()) << endl;
}


}
int scheduleProcesses(vector<Process> processes)
{
int minIndex = 0;
for (unsigned int i = 1; i < processes.size(); i++)
{
if (processes[i].getRequiredEndTime() < processes[minIndex].getRequiredEndTime())
{
minIndex = i;
}
}
return minIndex;
}


i'm not sure what i need to do with this. i'm completely lost
Please describe more detailed your requirement. Otherwise I'm also not sure what i need to do with this.
oki so basically the program has to return a list of processes that can be completed within the time frame. each process has a time is has to be completed by. however i have no idea on how to find out this time, or even how to find out the end required time.
if it will help i will give you the whole question just let me know
Sounds like some kind of realtime software? Ok, post your requirementd.
Topic archived. No new replies allowed.