#include #include #include #include #include #include using namespace std; class Random{ public: Random(bool pseudo=true); double random_real(); int poisson(double mean); private: int reseed(); int seed, multiplier,add_on; }; int Random::reseed() { seed=seed*multiplier + add_on; return seed; } Random::Random(bool pseudo) { if(pseudo) seed=1; else seed=time(NULL)%INT_MAX; multiplier=2743; add_on=5923; } double Random::random_real() { double max=INT_MAX + 1.0; double temp=reseed(); if(temp<0) temp=temp+max; return temp/max; } int Random::poisson(double mean) { double limit=exp(-mean); double product=random_real(); int count=0; while(product>limit){ count++; product*=random_real(); } return count; } /*******以上是随机数的生成和泊松分布的实现*******/ struct plane{ int name; int in_queue_time; } plane; int main() { int time=0,spare_time=0, wait_time=0, come_wait_time=0 , go_wait_time=0; int this_time_come=0, this_time_go=0, total_come=0, total_go=0; double come_rate=0,go_rate=0; int total=0,len=0, come_accepted=0, go_accepted=0; int i=0, counts=0; queue q1; //q1是准备降落的飞机队列 queue q2; //q2是准备起飞的飞机队列 struct plane temp; Random variable; printf("请输入飞机场运行的时间。\n"); scanf("%d",&time); printf("请输入降落和起飞队列最多容纳的飞机数。\n"); scanf("%d",&len); printf("请输入平均每个单位时间请求降落的飞机数。\n"); scanf("%lf",&come_rate); printf("请输入平均每个单位时间请求起飞的飞机数。\n"); scanf("%lf",&go_rate); for(i=0;i