0

The input looks like this:

Start 0
Run 40
Disk 0
Run 20
End

Each word and number means something. The number is the time and the word a command. What's the best way to loop through it and evaluate it? So it's 2 different elements per line that should evaluated seperately. Any ideas?

2
Contributors
2
Replies
4
Views
5 Years
Discussion Span
Last Post by XodoX
0

There are probably lots of ways to do it, but I would start out with a structure that contains two items: command and count. Then put the structure in an array or linked list. Once that is done it can be evaluated in a loop by iterating through the array or linked list.

0

The input is already being read by a linked list. I think I will put it into a queue...

struct Input_Table
{
    string p_num;       //process number
    string operation;   // word
    int parameter;
};

then I do:

queue<Input_Table> q;
Input_Table test, test2...

So, something like this? And you can loop through it once it's been put into the queue. A queue because there are many segments and each segment can be put into the queue and then get searched by the loop.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.