3.25 数据结构与算法作业——airport
个人觉得这道题很水没有什么思维难度也没有什么算法思想,只是很麻烦,因为用到的变量实在太多。
(也可能是有别的不麻烦的方法但我没想到orz)
还是记录一下吧,毕竟是第一个自己写的接近两百行的代码♪(・ω・)ノ
代码写的很繁琐,但觉得泊松分布部分写(chao) 的还挺好,蛮有参考价值的。。。
希望对有需要的人有帮助,同时希望看到的大佬能不吝赐教,指点指点怎么简化代码。。。
运行效果
先初始化
然后开始模拟
(中间调度过程:)
(最后机场调度情况总结:)
代码
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <queue>
#include <math.h>
#include <time.h>
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: