首页 > 其他 > 详细

队列框架

时间:2018-02-19 10:08:16      阅读:232      评论:0      收藏:0      [点我收藏+]
#include<iostream>
#define LEN 5010
using namespace std;
int Q[LEN],hand=0,tail=0; 
void enqueue(int x);
int dequeue();
bool isEmpty();
int main()
{

}

void enqueue(int x)
{
    Q[tail]=x;
    tail=(tail+1)%LEN;
}

int dequeue()
{
    if(isEmpty())
    {
    hand=(hand+1)%LEN;
    return Q[hand-1];
    }else return 0;    
}

bool isEmpty()
{
    if(tail==hand) 
    return 0;
    else 
    return 1;
}

 

队列框架

原文:https://www.cnblogs.com/incotnigo/p/8453417.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!