-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFCFS.cpp
More file actions
44 lines (33 loc) · 709 Bytes
/
Copy pathFCFS.cpp
File metadata and controls
44 lines (33 loc) · 709 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
32
33
34
35
36
37
38
39
40
41
42
43
44
#include<bits/stdc++.h>
int main()
{
int n,head,i,j,k,seek=0,max1,diff;
float avg;
printf("enter the max range of disk\n");
scanf("%d",&max1);
printf("enter the size of queue request\n");
scanf("%d",&n);
int queue[n+1];
printf("enter the queue\n");
for(i=1;i<=n;i++)
{
scanf("%d",&queue[i]);
}
printf("enter the initial head position\n");
scanf("%d",&head);
queue[0]=head;
for(j=0;j<=n-1;j++)
{
diff=abs(queue[j+1]-queue[j]);
seek+=diff;
}
for(i=1;i<=n;i++)
{
printf("%d ->",queue[i]);
}
printf("\n");
printf("total seek time is% d\n",seek);
avg=seek/(float)n;
printf("avrage seek time is %f\n",avg);
return 0;
}