import java.io.*;
class sjf
{
public static void main (String args[])throws IOException
{
int i,j,temp;
BufferedReader b= new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter no. of processes");
int p=Integer.parseInt(b.readLine());
int burst[]=new int[p];
System.out.println("Enter the burst time for each process");
for(i=0;i
burst[j+1])
{
temp=burst[j+1];
burst[j+1]=burst[j];
burst[j]=temp;
}
}
}
int arv[] = new int[p];
System.out.println("Enter arrival time for each process");
for(i=0;i
{
temp=burst[j+1];
burst[j+1]=burst[j];
burst[j]=temp;
}
}
}
int arv[] = new int[p];
System.out.println("Enter arrival time for each process");
for(i=0;i
arv[i]=Integer.parseInt(b.readLine());
int wait[] = new int[p];
System.out.println("Wait time for each process :");
System.out.println("Process 0 "+wait[0]+" units");
for(i=1;i
int wait[] = new int[p];
System.out.println("Wait time for each process :");
System.out.println("Process 0 "+wait[0]+" units");
for(i=1;i
{
wait[i]=arv[i-1]+burst[i-1]+wait[i-1]-arv[i];
System.out.println("Process "+i+" "+wait[i]+" units");
}
}
}
wait[i]=arv[i-1]+burst[i-1]+wait[i-1]-arv[i];
System.out.println("Process "+i+" "+wait[i]+" units");
}
}
}
0 comments :