标题:小试牛刀,队列问题
只看楼主
JJ是也
Rank: 2
等 级:论坛游民
帖 子:23
专家分:10
注 册:2012-1-16
结帖率:66.67%
 问题点数:0 回复次数:1 
小试牛刀,队列问题
程序代码:
#include
#include 

typedef struct LQNode
{
    int data;
    struct LQNode* next;
}LQNode, *LinkedQNode;

typedef struct
{
    struct LQNode* front,* rear;
}LQueue, *LinkedQueue;

LinkedQueue LinkedQueueInit ()
{
    LinkedQueue Q;
    LQNode* p;
    Q = (LinkedQueue) malloc (sizeof(LQueue));
    p = (LQNode*) malloc (sizeof(LQNode));
    p->next = NULL;
    Q->front = Q->rear = p;
    return Q;
}

void LinkedQueueIn (LinkedQueue Q, int x)
{
    LQNode* p;
    p = (LQNode*) malloc (sizeof(LQNode));
    p->data = x;
    p->next = NULL;
    Q->rear->next = p;
    Q->rear = p;
}

int LinkedQueueOut (LinkedQueue Q)
{
    LQNode* p;
    int x;
    if (Q->front=Q->rear)
    {
        p = Q->front->next;
        Q->front->next = p->next;
        x = p->data;
        free (p);
        if (Q->front->next==NULL)
            Q->rear = Q->front;
        return x;
    }
}

void main ()
{

    LinkedQueue Q;
    Q = LinkedQueueInit ();
    LinkedQueueIn (Q, 10);
    printf ("%d\n", LinkedQueueOut(Q));

}
搜索更多相关主题的帖子: next include color 
2012-05-21 18:22
JJ是也
Rank: 2
等 级:论坛游民
帖 子:23
专家分:10
注 册:2012-1-16
得分:0 
请大神打救打救 T_T
2012-05-21 18:23



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-367833-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.986311 second(s), 7 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved