Advertisement
Sri27119

fcfs

Nov 25th, 2024
14
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.62 KB | None | 0 0
  1. //1 fcfs
  2. #include <stdio.h>
  3.  
  4. int main()
  5. {
  6.     double avgtat, avgwt;
  7.     int at[] = {0,1,3,5};
  8.     int et[] = {5,4,3,3};
  9.     int ct[4], tat[4], wt[4];
  10.     int i, stat=0,swt=0;
  11.     ct[0] = at[0] + et[0] ;
  12.     for(i=1;i<4;i++)
  13.     {
  14.         ct[i] = ct[i-1] + et[i];
  15.     }
  16.     for(i = 0; i<4; i++)
  17.     {
  18.         tat[i] = ct[i] - at[i];
  19.         wt[i] = tat[i] - et[i];
  20.     }
  21.     for(i = 0; i<4; i++)
  22.     {
  23.         printf("%d      %d\n",tat[i],wt[i]);
  24.         stat+=tat[i];
  25.         swt+=wt[i];
  26.     }
  27.     avgtat=stat/4.0;
  28.     avgwt=swt/4.0;
  29.     printf("\n Avg tat=%f   Avg wt=%f",avgtat,avgwt);
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement