Ê ý Ý ***************************

Source: Internet
Author: User

When there are too many ******************************************************************

Limit µã £° n then limit µä % *********************************************************** ± Ç £ çâ ¼ Ò»  £%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


#include 
 
  #include 
  
   #define OK 1;#define ERROR -1;typedef int QElemType;typedef int Status;//¶¨Òå¶ÓÁнڵãtypedef struct QNode{    QElemType data;    struct QNode *next;}QNode, *QueuePtr;//¶ÓÁÐtypedef struct{    QueuePtr front;  //¶ÓÍ·Ö¸Õë    QueuePtr rear;   //¶ÓβָÕë}LinkQueue;//³õʼ»¯¶ÓÁÐStatus InitQueue(LinkQueue *q){    q->front = q->rear = (QueuePtr)malloc(sizeof(QNode));    if (!q->front) return ERROR;    q->front->next = NULL;    return OK;}//Ïú»Ù¶ÓÁÐStatus DestroyQueue(LinkQueue *q){    while(q->front){        q->rear = q->front->next;        free(q->front);        q->front = q->rear;    }    return OK;}//²åÈëÔªËØStatus EnQueue(LinkQueue *q, QElemType e){    QueuePtr p = (QueuePtr)malloc(sizeof(QNode));    if(!p) return ERROR;    p->data = e;    p->next = NULL;    q->rear->next = p; //¶ÓÁÐÄβָÏòp    q->rear = p; //p¼ÇΪβָÕë    return OK;}//³ö¶ÓÁÐStatus DeQueue(LinkQueue *q, QElemType *e){    if(q->front == q->rear) return ERROR;    QueuePtr p = q->front->next; //Ö¸Ïò¶ÓÁÐÍ·²¿µÚÒ»¸öÔªËØ    *e = p->data;    q->front->next = p->next;    if(q->rear == p) q->rear = q->front;    free(p);    return OK;}
  
 

³ Õ Ê» ¯ µäê ± ° ò, {0} front ° írear} {{{{******************************* 0, µ±è ¶ Ó 4 ö öö %%%%%%%%%%%%â Í %< %%%%http://www.bkjia.com/kf/ware/vc/ "" target = "_ blank" class = "keylink"> vcD48cD48aW1nIHNyYz0 = "http://www.2cto.com/uploadfile/Collfiles/20141203/20141203091316252.png" alt = "\"/>

'{± ± {Ó óááá {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%, ~~~~óáá~±ä~~~~~â {**************** rear <front


Máámámö» Ç ç¡ ° Â úā± £;{μ ± mááá~~iö ~~******************************************** please refer to the following link for more information:

#include 
 
  #include 
  
   #define OK 1#define ERROR -1#define MAXQSIZE 100 //×î´ó¶ÓÁ㤶Ètypedef int QElemType;typedef int Status;//Ñ»·¶ÓÁÐtypedef struct{    QElemType *base;    int front;    int rear;}SqQueue;//³õʼ»¯Ñ»·¶ÓÁÐStatus InitQueue(SqQueue *q){    q->base = (QElemType *)malloc(MAXQSIZE * sizeof(QElemType));    if (!q) return ERROR;    q->front = q->rear = 0;    return OK;}//»ñÈ¡¶ÓÁ㤶Èint QueueLength(SqQueue *q){    return (q->rear - q->front + MAXQSIZE) % MAXQSIZE;}//Èë¶ÓStatus EnQueue(SqQueue *q, QElemType e){    if ((q->rear + 1) % MAXQSIZE == q->front) {        return ERROR;    }    q->base[q->rear] = e;    q->rear = (q->rear + 1) % MAXQSIZE;    return OK;}//³ö¶ÓStatus DeQueue(SqQueue *q, QElemType *e){    if(q->front == q->rear) return ERROR;    *e = q->base[q->front];    q->front = (q->front + 1) % MAXQSIZE;    return OK;}
  
 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.