| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 528 人关注过本帖
标题:我这个简单的链队哪里错了,百思不得其解
只看楼主 加入收藏
飞黄腾达
Rank: 2
等 级:论坛游民
帖 子:46
专家分:27
注 册:2013-3-14
结帖率:29.41%
收藏
已结贴  问题点数:5 回复次数:1 
我这个简单的链队哪里错了,百思不得其解
#include<stdio.h>
#include<stdlib.h>
typedef struct node{
    int data;
    struct node *next;
}snode,*psnode;
typedef struct{
    psnode front,rear;
}Linkqueue,*pLinkqueue;
void In_queue(int x,pLinkqueue Qu)
{
    psnode p;
   
    p=(psnode)malloc(sizeof(psnode));
    if(!p)
    {
        printf("内存溢出\n");
    }
    p->data=x;
    p->next=NULL;
    if(!empty(Qu))
    {
        Qu->front=p;
        Qu->rear=p;
    }
    else
    {
        Qu->rear->next=p;
        Qu->rear=p;
    }
}
int empty(pLinkqueue q)
{
    if(q->front==NULL)
        return 0;
   
    else return 1;
}
int push_queue(pLinkqueue queue)
{
    int x;
    psnode sp;
    x=queue->front->data;
    sp=queue->front;
    queue->front=queue->front->next;
    free(sp);
    return x;
}


pLinkqueue creat_queue()
{
    pLinkqueue q;
    q=(pLinkqueue)malloc(sizeof(pLinkqueue));
    if(q)
    {
        q->front=NULL;
        q->rear=NULL;
    }
    return q;
}
int main()
{
    int a,b,n,i;
    pLinkqueue Q;
    Q=creat_queue();
    In_queue(0,Q);
    In_queue(1,Q);
    In_queue(0,Q);
    for(i=0;i<3;i++)
    printf("%d",push_queue(Q));
}
搜索更多相关主题的帖子: next void include 
2013-04-14 21:15
yuccn
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:何方
等 级:版主
威 望:167
帖 子:6814
专家分:42393
注 册:2010-12-16
收藏
得分:5 
把 这个函数挪到最前面。或者在最前面申明一下这个函数
int empty(pLinkqueue q)

我行我乐
公众号:逻辑客栈
我的博客:
https://blog.yuccn. net
2013-04-15 00:23
快速回复:我这个简单的链队哪里错了,百思不得其解
数据加载中...
 
   



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

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