gpt4 book ai didi

c - 快餐店模拟 : How to "queue" customers?

转载 作者:太空宇宙 更新时间:2023-11-04 00:52:32 25 4
gpt4 key购买 nike

<分区>

指向我的 PasteBin 的链接: http://pastebin.com/nzW3hZdT

I'm in the process of simulating a fast food restaurant over three hours. The three hours are divided into 18 intervals, consisting of 10 minutes each.

Based off an arrival rate of 'r' customers per minute, 'R' is established. R is the arrival rate, by probability, for all 18 intervals (which is more or less r/60).

The purpose of this simulation is to define 'r' ourselves and see the average waiting time (avgWait) of each customer in all 18 intervals. Generally, the greater the 'r', the greater the 'avgWait'.

此时在我的代码中(粘贴在上面),平均等待时间正确打印......对于一位客户。

假设第一位和第二位顾客分别在收银台 1 和收银台 2 接受订单大约需要 85 秒。在这 85 秒内,很有可能有更多的顾客到达,但是因为 cash1empty=FALSEcash2empty=FALSE 他们显然无法接受他们的订单。

我如何设置这个队列,以便程序知道在前两个订单得到服务后还有几个其他人在等待服务?

代码摘录:

if ((cash1empty==TRUE)&&(cash2empty==TRUE))
{
switch((rand()%2))
{
case 0:
cash1empty=FALSE;
break;
case 1:
cash2empty=FALSE;
break;

}
}

if (cash1empty==TRUE)
{
cash1empty=FALSE;

switch((rand()%2))
{
case 0:
cash1salad=(rand()%(66-55)+55);
totalWait+=cash1salad;
break;
case 1:
cash1burger=(rand()%(131-111)+111);
totalWait+=cash1burger;
break;
}
}
else if (cash2empty=TRUE)
{
cash2empty=FALSE;

switch(rand()%2)
{
case 0:
cash2salad=(rand()%(76-65)+65);
totalWait+=cash2salad;
break;
case 1:
cash2burger=(rand()%(141-121)+121);
totalWait+=cash2burger;
break;
}
}
else
{
queue++; // ???
/// I DON'T KNOW WHAT I'M DOING.
}

对于给您带来的不便,我深表歉意,但我不能使用“结构”。数组是可以接受的!

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com