Script for grocery shop with given inter-arrival/service time distribution assumed
by Amrendra Kumar mca/4549/09
#include
#include
#include
void addevent(int,int);
void depart();
void arrival();
struct eventinfo
{
int type;
int time;
struct eventinfo *next;
} * header;
int inter[9] = {1,1,6,3,7,5,2,4,1};
int service[9] = {4,2,5,4,1,5,4,1,4};
int i=0,j=0;
void main()
{
int t, eventtime;
clrscr();
header = (struct eventinfo *) malloc(sizeof(struct eventinfo));
header ->time=0;
header->next = NULL;
header->type = 0;
t =0;
addevent(0,1);
eventtime = header->next->time;
while(t<=60){if(t == eventtime){printf("\nt=%d ",t);if(header->next->type ==1)
arrival();
else
depart();
if(header->next != NULL)
eventtime = header->next->time;
else
eventtime = 100;
if(i>=9 || j>=9)
eventtime = 100;
}
t++;
if(t>eventtime)
t = eventtime;
}
getch();
}
void addevent(int time, int type)
{
struct eventinfo * node = (struct eventinfo *)malloc(sizeof(struct eventinfo));
struct eventinfo *p, *q;
node->type = type;
node -> time = time;
if(header->next == NULL)
{
header ->next = node;
node->next = NULL;
return ;
}
p = header->next;
q = header;
while((p->time
No comments:
Post a Comment