-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfcfs.cpp
More file actions
31 lines (30 loc) · 731 Bytes
/
fcfs.cpp
File metadata and controls
31 lines (30 loc) · 731 Bytes
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
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main()
{
int n;
int head = 0;
cout << "ENTER NUMBER OF REQUEST" << endl;
cin >> n;
n++;
int arr[n];
cout << "A list of cylinders" << endl;
for (int i = 1; i < n; i++)
{
arr[i] = rand() % 200;
cout << arr[i] << " ";
}
cout << endl;
int h;
cout << "Intial head position" << endl;
cin >> h;
cout << "\n Head start at:" << h << endl;
arr[0] = h;
for (int i = 0; i < n - 1; i++)
head += abs(arr[i + 1] - arr[i]);
cout << "\nTotal head movement is (" << head << ")";
cout << "\nSequence is" << endl;
for (int i = 0; i < n; i++)
cout << arr[i] << endl;
}