最近几天学习了队列,就想用class手打,这样可以不用STL的队列,还能再改,代码贴出来,分享给大家,也能给自己做个记录(可能不对,有大神可帮改一下)
class queue{
const int mcx=1e6+5;
int q[mcx],h=1,t=0;
public:
void push(int x){
q[++t]=x;
}
int front(){
return q[h];
}
void pop(){
h++;
}
int size(){
return t-h+1;
}
bool empty(){
return h=t+1;
}
};