题目内容:使用的排队现象,通过仿真手法评估其营业状况。
*基本要求:设某理发馆有N把理发椅,可同时为N位顾客进行理发。
*当顾客进门时,若有空椅,则可以立即坐下理发,否则需要依次排队等候。
*一旦有顾客理完发离去时,排在队头的顾客便可开始理发。
*若理发馆每天连续营业T小时,求一天内顾客在理发馆内的平均逗留时间
*顾客排队等候的队列平均长度
N和T在运行的时候输入
用C#写的,有注释,很混乱,请高人指教~~
- using System;
- using System.Collections.Generic;
- using System.Text;
- using System.Collections;
- namespace 队列应用
- {
- class Seat
- {
- public bool IsFree;
- public Customer cus=null;
- public Seat(bool b)
- {
- IsFree = b;
- }
- }
- class Customer
- {
- public int cometime;
- public int timetogo;
- public int cost =30- new Random().Next(10);//理发需要20~30分钟
- public Customer() { }
- }
- class Program
- {
- static void Main(string[] args)
- {
- System.Console.WriteLine("每天营业多少小时?");
- int workinghours = int.Parse(Console.ReadLine());
- System.Console.WriteLine("有多少个椅子?");
- int seats = int.Parse(Console.ReadLine());
- Process(seats,workinghours);
- Console.ReadLine();
- }
- static void Pr