#include <stdio.h>
#include <stdlib.h>
int main()
{
int bt[10] = {0}, at[10] = {0}, tat[10] = {0}, wt[10] = {0}, ct[10] = {0};
int n, sum = 0;
int totaltat = 0, totalwt = 0;
system("clear");
printf("Enter the number of the process : ");
scanf("%d",&n);
printf("Enter the arrival time and bust time :
");
for( int i = 0; i < n; ++i)
{
printf("Enter the arrival time %d : ", i+1 );
scanf("%d",&at[i]);
printf("Enter the burst time %d : ", i+1 );
scanf("%d",&bt[i]);
printf("
");
}
for( int j = 0; j < n; ++j )
{
sum += bt[j];
ct[j] += sum;
}
for( int i = 0; i < n; ++i )
{
tat[i] = ct[i]-at[i];
totaltat += tat[i];
}
for( int k = 0; k < n; ++k )
{
wt[k] = tat[k]-bt[k];
totalwt = wt[k];
}
printf("solutions :
");
printf("P AT BT CT TAT WT
");
for( int i = 0; i < n; ++i )
{
printf("%d %d %d %d %d %d
",i+1,at[i],bt[i],ct[i],tat[i],wt[i]);
}
printf("Average TAT time : %.2f
", totaltat/(float)n);
printf("Average waiting time : %.2f
",totalwt/(float)n);
return 0;
}