#include<stdio.h>
#include<conio.h>
void main()
{
int i,n, tba[10],st[10],at[10],tsb[10],tcw[10],tse[10],tcss[10];
clrscr();
printf("enter no. of customers:");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("\n customer %d",i+1);
printf("\nTime between arrivals:");
scanf("%d",&tba[i]);
printf("Service time:");
scanf("%d",&st[i]);
}
for(i=0;i<n;i++)
{
if(i==0)
{
at[0]=0;
tsb[0]=0;
tse[0]=tsb[0]+st[0];
tcw[0]=0;
tcss[0]=tse[0]-at[0];
}
else
{
at[i]=at[i-1]+tba[i];
if(at[i]<=tse[i-1])
tsb[i]=tse[i-1];
else
tsb[i]=at[i];
tse[i]=tsb[i]+st[i];
tcw[i]=tsb[i]-at[i];
tcss[i]=st[i]+tcw[i];
}
}
printf("Cus\t Tba\t St\t At\t Tsb\t Tcw\t Tse\t Tcss\n");
printf("---------------------------------------------------------------------\n");
for(i=0;i<n;i++)
{
printf("%d\t %d\t %d\t %d\t %d\t %d\t %d\t %d\n",i+1,tba[i],st[i],at[i],tsb[i],tcw[i],tse[i],tcss[i]);
}
getch();
}
#include<conio.h>
void main()
{
int i,n, tba[10],st[10],at[10],tsb[10],tcw[10],tse[10],tcss[10];
clrscr();
printf("enter no. of customers:");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("\n customer %d",i+1);
printf("\nTime between arrivals:");
scanf("%d",&tba[i]);
printf("Service time:");
scanf("%d",&st[i]);
}
for(i=0;i<n;i++)
{
if(i==0)
{
at[0]=0;
tsb[0]=0;
tse[0]=tsb[0]+st[0];
tcw[0]=0;
tcss[0]=tse[0]-at[0];
}
else
{
at[i]=at[i-1]+tba[i];
if(at[i]<=tse[i-1])
tsb[i]=tse[i-1];
else
tsb[i]=at[i];
tse[i]=tsb[i]+st[i];
tcw[i]=tsb[i]-at[i];
tcss[i]=st[i]+tcw[i];
}
}
printf("Cus\t Tba\t St\t At\t Tsb\t Tcw\t Tse\t Tcss\n");
printf("---------------------------------------------------------------------\n");
for(i=0;i<n;i++)
{
printf("%d\t %d\t %d\t %d\t %d\t %d\t %d\t %d\n",i+1,tba[i],st[i],at[i],tsb[i],tcw[i],tse[i],tcss[i]);
}
getch();
}
No comments:
Post a Comment