1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
#include <iostream>
#include <queue>
struct Task
{
int pID;
int initialPriority;
int currentPriority;
int totalRunTime;
int remainingRunTime;
};
void printQueue(std::queue<Task>&);
int main()
{
std::queue<Task> taskQueue;
Task temp = { 10, 20, 30, 40, 50 };
taskQueue.push(temp);
temp = { 50, 40, 30, 20, 10 };
taskQueue.push(temp);
temp = { 100, 200, 500, 357, 98 };
taskQueue.push(temp);
temp = { 55, 45, 101, 12, 1002 };
taskQueue.push(temp);
printQueue(taskQueue);
}
void printQueue(std::queue<Task>& taskQueue)
{
Task temp;
while (!taskQueue.empty())
{
temp = taskQueue.front();
std::cout << temp.pID << ", "
<< temp.initialPriority << ", "
<< temp.currentPriority << ", "
<< temp.totalRunTime << ", "
<< temp.remainingRunTime << "\n";
taskQueue.pop();
}
}
|