Question: In C++, read the lines from a file given below and store them in the format discussed. Print them out afterwards to show your work

In C++, read the lines from a file given below and store them in the format discussed. Print them out afterwards to show your work

Each process is on one line of the file (after the first line). Each line consists of a series of integers that describe (in order):

First, the arrival time of the process (that is, when it is submitted): a positive integer.- store this as an int value.

After the arrival time, a series of CPU burst times (positive integers) and I/O burst times (negative integers): this list will contain at least one CPU burst time, and every process starts with a CPU burst. After the initial CPU time, the list may contain alternating I/O and CPU burst times. There is no maximum length for this list, but the information for each process will be contained on one line. The I/O bursts are listed as negative numbers for identification, but they represent positive values in reality.

For example, a line with this data

2 8 -20 4 -10 2

describes a process arriving at time 2, which requires 3 CPU bursts (length 8, 4 and 2) and 2 I/O bursts (length 20 and 10). Use two int arrays to store the CPU bursts and IO bursts separately. Find the sample test data below:

Sampledata.txt:

3

2 8 -20 4 -10 2

5 2 -22

6 6 -12 4

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!