基于链表实现队列
来源:互联网 发布:get软件 编辑:程序博客网 时间:2024/05/19 09:09
#ifndef LINK_QUEUE_H#define LINK_QUEUE_Hstruct linkqueue{struct linkqueue * next;int content;};struct linkqueue * pop();void push(struct linkqueue * p);void display();void init(int * array , int n);#endif
#include <stdio.h>#include <stdlib.h>#include "linkqueue.h"/* *link queue *author @ suilingxi *2014-1-29*/struct linkqueue * head;struct linkqueue * tail;int main(){return 0;}void init(int * array , int n){if(n==0){head=NULL;tail=NULL;}else if(n>0){struct linkqueue * node;node=(struct linkqueue *)malloc(sizeof(struct linkqueue));node->content=*array;node->next=NULL;head=node;tail=node;for(int i=1;i<n;i++){struct linkqueue * node;node=(struct linkqueue *)malloc(sizeof(struct linkqueue));node->content=*(array+i);node->next=NULL;tail->next=node;tail=node;}}}void display(){if((head==NULL)&&(tail==NULL)){printf("null\n");}else{struct linkqueue * tmp;tmp=head;while(tmp != NULL){printf("%d-->",tmp->content);tmp=tmp->next;}}printf("\n");}struct linkqueue * pop(){struct linkqueue * tmp;if(head==NULL){return NULL;}else if(head == tail){tmp=head;head=NULL;tail=NULL;}else{tmp=head;head=head->next;}return tmp;}void push(struct linkqueue * p){if(head == NULL){head=p;tail=p;}else{tail->next=p;tail=p;}}
0 0
- 基于链表实现队列
- 基于链表的队列实现
- 基于链表的队列实现
- 基于链表、数组实现队列、循环队列
- 典型数据结构--基于链表的队列实现
- 简单队列的实现(基于链表)
- 基于数组和链表的队列实现
- 【数据结构练习】基于链表结构实现的队列
- 基于链表实现Java 自定义Queue队列
- java基于有序链表的优先级队列实现
- 基于visual Studio2013解决算法导论之022队列实现(基于链表)
- Java 实现双向链表,基于双向链表实现双端队列
- 基于数组的队列实现
- 基于 rabbitmq 实现延迟队列
- 基于 rabbitmq 实现延迟队列
- 基于数组的队列实现
- 基于Redis实现延迟队列
- 链表实现队列
- 火地晉 (易經大意 韓長庚)
- freopen
- Loader,AsyncTaskLoader,CursorLoader,LoaderManager 相关
- 雷天大壯 (易經大意 韓長庚)
- linux基础
- 基于链表实现队列
- 苹果移动设备密码破解
- 沉下心来,回顾一下,欣赏自己拥有的和所完成的
- 如是我闻
- 一种Intel Outside的壁挂式desktop电脑DIY
- vim学习笔记
- 2013之公司篇
- .2 HOST主桥(2)
- Microsoft NLayerApp案例理论与实践【多层架构与应用系统设计原则】