Shortest Job Next

2 Comments

C program for Shortest Job Next

C program for Shortest Job Next #include<stdio.h> #include<conio.h> #include<math.h> void main() { int s,t[20],temp,n,x[20],w[20],i,j,c,d,b[20]; float avgw,avgt; clrscr(); printf("\n Enter no.of job:"); scanf("%d",&n); printf("enter the job:"); for(i=1;i<=n;i++) { scanf("%d",&b[i]); x[i]=i; } for(i=1;i<=n-1;i++) { for(j=i+1;j<=n;j++) { if(b[i]>b[j]) { temp=b[i]; b[i]=b[j]; b[j]=temp; s=x[i]; x[i]=x[j]; x[j]=s; } } } c=0; d=0; for(i=1;i<=n;i++) { w[i]=w[i-1]+b[i-1]; t[i]=b[i]+t[i-1]; w[1]=0; t[1]=b[1]; c+=w[i]; d+=t[i]; […]