Write a program in C that implements the FCFS and SCAN disk
Write a program in C that implements the FCFS and SCAN disk scheduling
 algorithms.
 
 The disk in question has 5000 tracks.
 
 1.) generate a list of 100000 random track numbers that are greater than
 or equal to 0
     and less than 5000.
2.) segment your track addresses into groups of 1000, sort them
 according to the algorithm
 
 3.) Calculate the number of tracks traveled for each group
 
 4.) Report the total number of tracks traveled for each algorithm.
 
 
 Example:
     for this example we’ll segment in groups of 5 addresses
     generated list of random tracks
         5 12 3 4 34 25 22 33 51 1
     the groups would be:
         5 12 3 4 34
         25 22 33 51 1
 
     The sorting would be
         FCFS:
             5 12 3 4 34
             25 22 33 51 1
 
         SCAN:
             3 4 5 12 34
             51 33 25 22 1
 
     The tracks traveled would be:
         FCFS:
             5 + 7 + 9 + 1 + 30
             9 + 3 + 11 + 19 + 51
             total = 145
 
         SCAN:
             3 + 1 + 1 + 7 + 22 + 4965
             4948 + 18 + 8 + 3 + 21
             total = 9998
Solution
#include<stdio.h>
int main()
{
int s[100][1000];
int i,j;
for(i = 0;i < 100;i++)
{
j = 0;
while(j < 1000)
{
s[i][j] = rand() % 5000;
j++;
}
}
for (i = 0;i < 100;i++)
{
int disks = 0;
int cur = 0;
int dif = 0;
for(j = 0;j < 1000;j++)
{
diff = cur - s[i][j];
if ( diff < 0)
diff = diff * -1;
disks += diff;
cur = s[i][j];
}
cout<<\"#FCFS \"<<i+1<<\" \"<<disks;
}
}


