Sumit Prasad (MCA/4521/10)
#include
#include
#include
int interarr(int rand)
{
if(rand>=0&&rand<=12)
return 1;
if(rand>=13&&rand<=25)
return 2;
if(rand>=26&&rand<=37)
return 3;
if(rand>=38&&rand<=50)
return 4;
if(rand>=51&&rand<=62)
return 5;
if(rand>=63&&rand<=75)
return 6;
if(rand>=76&&rand<=87)
return 7;
if(rand>=88&&rand<=99)
return 8;
return 0;
}
int main()
{
int arrival=0,s[10],ia,idle=0,st,servend,servbegin=0,r[10],i,wt=0,notice[2][2];
char ch='A';
clrscr();
for(i=0;i<10 i="i" p="p"> {
r[i]= rand()%100;
s[i]=rand()%100;
}
printf("Sno.Interarr Arr Servtime Servbegin Servend WT Idle Event Fel\n");
for(i=0;i<5 i="i" p="p">{
ia=interarr(r[i]);
st=interarr(s[i]);
servend=servbegin+st;
wt=servbegin-arrival;
if(i>0)
printf("(%d,%c),(%d,%c)\n\n",notice[0][0],notice[0][1],notice[1][0],notice[1][1]);
printf("%3d%5d%7d%5d%10d%8d%7d%5d (%c,%d) ",
i,ia,arrival,st,servbegin,servend,wt,idle,ch,servbegin);
arrival=arrival+ia;
if(servend>arrival)
servbegin=servend;
else
servbegin=arrival;
idle=servbegin-servend;
if(servend>arrival)
{
notice[0][0]=arrival;
notice[0][1]=ch+1;
notice[1][0]=servend;
notice[1][1]=ch;
}
else
{
if(i==0)
{
notice[0][0]=servend;
notice[0][1]=ch;
notice[1][0]=arrival;
notice[1][1]=ch+1;
}
else
{
notice[0][0]=servend;
notice[0][1]=ch;
notice[1][0]=arrival;
notice[1][1]=ch+1;
}
}
ch=ch+1;
}
printf("(%d,%c)\n\n",notice[0][0],notice[0][1]);
getch();
return 0;
}
5>10>
#include
#include
#include
int interarr(int rand)
{
if(rand>=0&&rand<=12)
return 1;
if(rand>=13&&rand<=25)
return 2;
if(rand>=26&&rand<=37)
return 3;
if(rand>=38&&rand<=50)
return 4;
if(rand>=51&&rand<=62)
return 5;
if(rand>=63&&rand<=75)
return 6;
if(rand>=76&&rand<=87)
return 7;
if(rand>=88&&rand<=99)
return 8;
return 0;
}
int main()
{
int arrival=0,s[10],ia,idle=0,st,servend,servbegin=0,r[10],i,wt=0,notice[2][2];
char ch='A';
clrscr();
for(i=0;i<10 i="i" p="p"> {
r[i]= rand()%100;
s[i]=rand()%100;
}
printf("Sno.Interarr Arr Servtime Servbegin Servend WT Idle Event Fel\n");
for(i=0;i<5 i="i" p="p">{
ia=interarr(r[i]);
st=interarr(s[i]);
servend=servbegin+st;
wt=servbegin-arrival;
if(i>0)
printf("(%d,%c),(%d,%c)\n\n",notice[0][0],notice[0][1],notice[1][0],notice[1][1]);
printf("%3d%5d%7d%5d%10d%8d%7d%5d (%c,%d) ",
i,ia,arrival,st,servbegin,servend,wt,idle,ch,servbegin);
arrival=arrival+ia;
if(servend>arrival)
servbegin=servend;
else
servbegin=arrival;
idle=servbegin-servend;
if(servend>arrival)
{
notice[0][0]=arrival;
notice[0][1]=ch+1;
notice[1][0]=servend;
notice[1][1]=ch;
}
else
{
if(i==0)
{
notice[0][0]=servend;
notice[0][1]=ch;
notice[1][0]=arrival;
notice[1][1]=ch+1;
}
else
{
notice[0][0]=servend;
notice[0][1]=ch;
notice[1][0]=arrival;
notice[1][1]=ch+1;
}
}
ch=ch+1;
}
printf("(%d,%c)\n\n",notice[0][0],notice[0][1]);
getch();
return 0;
}
5>10>
Comments