Compare commits

...

16 Commits
z ... master

Author SHA1 Message Date
刘彩月 6459ee87b8 123
2 years ago
刘彩月 d0895cbae9 100
2 years ago
刘彩月 7a98d031e2 s23
2 years ago
yujia jin 345ae2c142 123
2 years ago
yujia jin 8877b0cfa1 123
2 years ago
yujia jin 975a5ea13c Merge branch 'master' of https://bdgit.educoder.net/p253vfkpe/text2
2 years ago
yujia jin 72cd25e959 Merge branch '金雨佳'
2 years ago
yujia jin 446ef0c8a9 123
2 years ago
刘彩月 3d295606b6 123
2 years ago
刘彩月 66680458fd Merge branch '刘梦琦'
2 years ago
刘彩月 8b4e8c60f1 1
2 years ago
刘梦琦 8baabc6757 刘梦琦
2 years ago
yxzhao_iebd22 f011def748 Merge branch '赵亚璇'
2 years ago
yxzhao_iebd22 993b3e7b73 2
2 years ago
刘彩月 0f8e0280e7 Merge branch '赵亚璇'
2 years ago
刘彩月 7652563202 1
2 years ago

File diff suppressed because it is too large Load Diff

@ -40,7 +40,6 @@ QueuePtr front;//队头指针
QueuePtr rear; // 队尾指针
} LinkQueue;
EventList ev; // 事件表
Event en; // 事件
LinkQueue q[5]; // 四个客户队列
@ -108,9 +107,12 @@ printf("The Average Time is %f\n", (float)TotalTime / CustomerNum);
}
int cmp(Event a, Event b) // 比较事件发生先后
{
if (a.OccurTime > b.OccurTime) return 1;
if (a.OccurTime = b.OccurTime) return 0;
if (a.OccurTime < b.OccurTime) return -1;
if (a.OccurTime > b.OccurTime)
return 1;
if (a.OccurTime = b.OccurTime)
return 0;
if (a.OccurTime < b.OccurTime)
return -1;
}
void OpenForDay() // 银行开门
@ -162,19 +164,18 @@ OrderInsert(ev, { en.OccurTime + durtime,i }, cmp);//队列长度为1时
}
}
void CustomerDepature() // 客户离开
{
int i = en.NType;
DeQueue(q[i], customer); // 删除第i队列的排头客户
TotalTime += en.OccurTime - customer.ArrivalTime; // 累计客户逗留时间
if (!QueueEmpty(q[i])) {
if (!QueueEmpty(q[i]))
{
GetHead(q[i], customer);
OrderInsert(ev, {en.OccurTime + customer.Duration, i}, cmp); // 插入事件
}
}
int Minimum(LinkQueue Q[5]) // 求长度最短队列
{
int minLength = QueueLength(Q[1]);
@ -190,7 +191,6 @@ i = j;
return i;
}
Status InitList(LinkList &L) // 链表初始化
{
L = (LinkList)malloc(sizeof(LNode));
@ -265,12 +265,14 @@ ListTraverse(ev);
Status ListTraverse(LinkList &L) // 遍历链表  
{
LNode *p = L->next;
if (!p) {
if (!p)
{
printf("List is empty.\n");
return ERROR;
}
while (p != NULL) {
while (p != NULL)
{
printf("OccurTime:%d,Event Type:%d\n", p->data.OccurTime, p->data.NType);
p = p->next;
}
@ -278,8 +280,6 @@ printf("\n");
return OK;
}
Status InitQueue(LinkQueue &Q) // 链队列的初始化
{
Q.front = Q.rear = (QueuePtr)malloc(sizeof(QNode));
@ -324,7 +324,8 @@ int QueueLength(LinkQueue Q)//返回队列的长度
{
int count = 0;
QNode *p = Q.front->next;
while (p) {
while (p)
{
p = p->next;
count++;
}
@ -334,7 +335,9 @@ return count;
Status GetHead(LinkQueue Q, QElemType &e) // 获取队头元素
{
if (Q.front == Q.rear)
{ return ERROR;}
{
return ERROR;
}
e = Q.front->next->data;
}
Status QueueEmpty(LinkQueue Q) // 判断队列是否为空
@ -349,7 +352,8 @@ void PrintQueue()//打印队列
{
// 打印当前队列  
int i;
for (i = 1; i <= 4; i++) {
for (i = 1; i <= 4; i++)
{
printf("窗口 %d 有 %d 个客户:", i, QueueLength(q[i]));
QueueTraverse(q[i]);
}
@ -358,11 +362,13 @@ printf("\n");
Status QueueTraverse(LinkQueue Q) // 遍历队列Q  
{
QNode *p = Q.front->next;
if (!p) {
if (!p)
{
printf("--Is empty.\n");
return ERROR;
}
while (p) {
while (p)
{
printf("(到达时刻 %d min 办理业务需要花费 %d min) ", p->data.ArrivalTime, p->data.Duration);
p = p->next;
}

Binary file not shown.
Loading…
Cancel
Save