#include<stdio.h>
#include<string.h>
float avgwt,avgtt;
char pname[10][10],c[10][10];
int wt[10],tt[10],bt[10],n,sum=0,ttime,j,ss=0,count=0,indexar[10],ix=0,k,ix1,ix2,choice,ct[10],i;
void table(){
int i;
printf("\nPROCESS\t\tBT\t\tWT\t\tTT\t");
for(i=0;i<n;i++){
printf("\n%s\t\t\t%d\t\t%d\t\t%d\t",pname[i],bt[i],wt[i],tt[i]);
}
}
void gantt_chart(){
int i;
printf("\nGANTT CHART\n");
for(i=0;i<n;i++){
printf("|\t%s\t",pname[i]);
}printf("|");
printf("\n");
printf("0\t\t");
for(i=0;i<n;i++){
for(int j=0;j<n;j++){
if(bt[i]<bt[j]){
int temp=bt[i];
bt[i]=bt[j];
bt[j]=temp;
char tempStr[10];
strcpy(tempStr,pname[i]);
strcpy(pname[i],pname[j]);
strcpy(pname[j],tempStr);
}
}
}
wt[0]=0;
ct[0]=bt[0];
sum=0;
tt[0]=wt[0]+bt[0];
ss=tt[0];
for(int i=1;i<n;i++){
ct[i]=ct[i-1]+bt[i];
tt[i]=ct[i];
wt[i]=tt[i]-bt[i];
sum=sum+wt[i];
ss=ss+tt[i];
}
avgwt=(float)sum/n;
avgtt=(float)ss/n;
printf("\nAVG WAITING TIME=%f",avgwt);
printf("\nAVG TURN AROUND TIME=%f",avgtt);
printf("\nGANTT CHART SJF SCHEDULING\n");
table();
gantt_chart();
return 0;
}
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}