#include<stdio.h> #include<malloc.h> #include<stdlib.h> int i,j,k,l,n,l1,st,flag,x,x1,x2,x3; int main() { FILE *ft; int p[100],ar[100],b[100],temp,p1[100],ar1[100],b1[100]; int ct[100],bt[100],tatm[100],sum=0,wt[100],ct1[100]; char *temp1,*str[ ] ={"p1","p2","p3","p4","p5","p6","p7","p8","p9"},*str1[20],*str2[100]; float sum1=0.0,sum2=0.0,av=0.0,tat=0.0; printf("\n taking input from file\n"); ft=fopen("mst1.dat","r"); if(ft==NULL) { printf("\n File dosent Exist"); exit(0); } i=0; while(fscanf(ft,"%d%d%d",&x1,&x2,&x3)!=EOF) p[i]=x1,ar[i]=x2,b[i++]=x3; n=i; k=i; for(i=0;iar[j]) { temp=ar[i]; ar[i]=ar[j]; ar[j]=temp; temp=p[i]; p[i]=p[j]; p[j]=temp;
");
temp=b[i]; b[i]=b[j]; b[j]=temp; temp1=str[i]; str[i]=str[j]; str[j]=temp1; } } } // end of first sorting... ct[0]=ar[0]; sum=0; j=0; flag=0; while(1) { for(i=0;i=st) { l=0; l=b[i]-st; b[i]=l; sum+=st; ct[j+1]=sum; str2[j]=str[i]; j++; } else if(b[i]>0 && b[i]<st) { l=0; sum+=b[i]; ct[j+1]=sum; b[i]=l; str2[j]=str[i]; j++; } }// end of for loop....
}
for(i=0;i0) { flag=0; break; } } if(flag==1) break;
n=j; for(i=0;i
cmplt tym
%d
wtng
%d
} printf("\n %d ",ct[0]); for(i=1;i<=n;i++) { printf(" %d ",ct[i]); } printf("\n"); printf("\nAvearge waiting time=%f",av); printf("\n\nAverage turn around time=%f\n\n",tat); fclose(ft); return 0; }// end of main