队列

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// 队尾插入元素,队头弹出元素
int q[N], hh=0, tt=-1; // 队头head, 队尾tail

// 插入
q[++tt] = x;

//弹出
hh++;

// 判断是否为空
if(hh<=tt) not empty;
else empty;

// 取出队头元素
q[hh]