求用c语言队列实现做队列的出对和入队

#include&iostream&#include&stdio.h&#include&string.h&#include&conio.h&typedef struct student{struct student *}typedef struct linkqueue{node *first, *}//队列的入队queue *insert(queue *HQ, int x){node *s;s = (node*)malloc(sizeof(node));s-&data = http://blog.csdn.net/wangfengfan1/article/details/x;s-&next = NULL;if (HQ-&rear == NULL){HQ-&first =HQ-&rear =}else{HQ-&rear-&next =HQ-&rear =}}//队列出队queue *del(queue *HQ){node *p;if (HQ-&first == NULL){printf(&\n yichu&);}else{x = HQ-&first-&p = HQ-&if (HQ-&first == HQ-&rear){HQ-&first = NULL;HQ-&rear = NULL;}else{HQ-&first = HQ-&first-&free(p);}return (HQ);}}
版权声明:本文为博主原创,未经博主允许不得转载。Queue 队列的基本操作,出队、入队 的 用C语言实现 Data structs 数据结构 238万源代码下载-
&文件名称: Queue
& & & & &&]
&&所属分类:
&&开发工具: Visual C++
&&文件大小: 1 KB
&&上传时间:
&&下载次数: 2
&&提 供 者:
&详细说明:队列的基本操作,出队、入队等基本的操作,用C语言实现-The basic operation of the basic operation of the queue, the queue, the queue, with the C language
&输入关键字,在本站238万海量源码库中尽情搜索:
&[] - 链表的基本操作,包括建立、遍历、删除、添加等
&[] - estadistics homeworkC语言 用单链表实现队列_百度知道采用链式存储实现队列的初始化、入队、出队操作
#include&stdio.h&
#include&stdlib.h&
#define OK 1
#define OVERFLOW
#define ERROR
typedef&int&QElemT
typedef&int&Status&;
typedef&struct&QNode{
&QElemType&
& &struct&QNode&*
}QNode,*QueueP
typedef&struct&{
&QueuePtr&
&QueuePtr&
Status&InitQueue(LinkQueue&&Q){
&Q.front=(QueuePtr)malloc(sizeof(QNode));
&Q.rear=(QueuePtr)malloc(sizeof(QNode));
& &if(!Q.front)exit(OVERFLOW);
& &Q.front=Q.
& &return&OK;
Status&Chushihua(LinkQueue&&Q){
&QueuePtr&p;
& &printf("请输入元素,以-1 结束\n");
& &while(scanf("%d",&e),e!=-1){
&p=(QueuePtr)malloc(sizeof(QNode));
&p-&data=e;
&p-&next=NULL;
&Q.rear-&next=p;
&Q.rear=p;
&p=Q.front-&
& &while(p!=NULL)
&printf("%d
",p-&data);
& &printf("\n");
& &return&OK;
void&tishi()
& &printf("所有操作如下:\n");
& &printf("(1)采用链式存储实现队列的初始化操作。\n");
& &printf("(2)采用链式存储实现队列的入队操作。\n");
& &printf("(3)采用链式存储实现队列的出队操作。\n");
& &printf("(-1)退出\n");
& &printf("请选择:");
Status&DeQueue(LinkQueue&&Q){
&QueuePtr&p;
& &if(Q.front==Q.rear)
&printf("队列为空!!!!!!!!\n");
&return&ERROR;
&p=Q.front-&
& &printf("%d\n",p-&data);
&Q.front-&next=p-&
& &if(Q.rear==p)Q.rear=Q.
& &free(p);
& &return&OK;
Status&EnQueue(LinkQueue&&Q){
&QueuePtr&p;
&p=(QueuePtr)malloc(sizeof(QNode));
& &if(!p)exit(OVERFLOW);
& &printf("请输入要入队的元素:");
& &scanf("%d",&p-&data);
&Q.rear-&next=p;
&p-&next=NULL;
& &Q.rear=p;
& &return&OK;
int&main()
&LinkQueue&q;
& &InitQueue(q);
&scanf("%d",&m);
&switch(m){
&Chushihua(q);
&EnQueue(q);
&DeQueue(q);
& &}while(m!=-1);
& &return&0;
已投稿到:
以上网友发言只代表其个人观点,不代表新浪网的观点或立场。}

我要回帖

更多关于 c语言队列 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信