c语言大数据结构的出队入队程序.docx

上传人:scccc 文档编号:14682028 上传时间:2022-02-11 格式:DOCX 页数:4 大小:12.14KB
返回 下载 相关 举报
c语言大数据结构的出队入队程序.docx_第1页
第1页 / 共4页
c语言大数据结构的出队入队程序.docx_第2页
第2页 / 共4页
c语言大数据结构的出队入队程序.docx_第3页
第3页 / 共4页
c语言大数据结构的出队入队程序.docx_第4页
第4页 / 共4页
亲,该文档总共4页,全部预览完了,如果喜欢就下载吧!
资源描述

《c语言大数据结构的出队入队程序.docx》由会员分享,可在线阅读,更多相关《c语言大数据结构的出队入队程序.docx(4页珍藏版)》请在三一文库上搜索。

1、实用标准文案#include stdio.h#include #include typedef int Status;#define TRUE 1#define FALSE 0#define OK 1#define ERROR 0#define OVERFLOWS/定义类型typedef int QElemType;typedef struct NodeQElemType data;struct Node * next; QNode*QueuePtr; typedef struct QueuePtr front;QueuePtr rear;*LinkQueue;/初始化void InitQue

2、ue(LinkQueue *Q)(*Q)-front =(QueuePtr)malloc( sizeof (QNode);if (! (*Q)-front)exit(OVERFLOW);(* Q)- rear =( * Q)-front;(*Q)-front -next =NULL;/入队Status EnQueue(LinkQueue Q,QElemType e)QueuePtr s;s=(QueuePtr)malloc( sizeof (QNode);if (! s)exit(OVERFLOW);Q- rear - next =s;s-data =e;Q- rear =s;精彩文档实用标准

3、文案s-next =NULLreturn (OK);)/出队Status DeQueue(LinkQueue Q,QElemType *e)(QueuePtr p;if (Q-front =Q- rear) return (ERROR);p=C- front - next;*e=p-data;Q- front - next =p- next;if (Q- rear =p)Q- rear =Q front;return OK;)/输出队列void PrintQueue(LinkQueue Q)(QueuePtr p;p=Q- front - next;while (p)printf( %d ,p

4、-data);p =p-next; )/主函数void main()LinkQueue Q;QElemType n,e;InitQueue( &Q);printf(输入数据,输入0为结束,输入奇数为入队,输入偶数为出队n);scanf( %d, &n);printf( n);while (n)if (n %=0)if (! DeQueue(Q&e) printf(输入错误 n );exit(OVERFLOW);else printf(队头元素是:d:e); else EnQueue(Q,n);printf(队列为:);PrintQueue(Q);printf( n);scanf( %d, &n);精彩文档实用标准文案printf( n);)精彩文档

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 社会民生


经营许可证编号:宁ICP备18001539号-1