数据结构--链队
来源:互联网 发布:淘宝卖家如何改差评 编辑:程序博客网 时间:2024/05/22 05:01
#include <stdio.h>#include <stdlib.h>typedef struct queue{ int data; struct queue * next;}q;q * front;q * rear; void init(void);void push(int );void pop(void);int frontdata(void);int main(void){ init(); push(10); push(1000); push(100); pop(); pop(); printf("%d\n", frontdata()); return 0;} int frontdata(void){ return front->next->data;}void pop(void){ q * t; t = front->next; front->next = front->next->next; if (rear == t) rear = front; free(t);}void push(int k){ q * newnode; newnode = (q *)malloc(sizeof(q)); newnode->data = k; newnode->next= NULL; rear->next = newnode;//将新节点插入队尾 rear = newnode;//修改队尾指针 }void init(void){ front = (q *)malloc(sizeof(q)); rear = front; front->next = NULL;}
0 0
- 数据结构-链队
- 数据结构--链队
- 数据结构(三)-链队
- 数据结构
- 数据结构
- 数据结构
- 数据结构
- 数据结构
- 数据结构
- 数据结构
- 数据结构
- 数据结构
- 数据结构
- 数据结构
- 数据结构
- 数据结构
- 数据结构
- 数据结构
- Eclipse EE+MAVEN配置以及POM.XML的使用
- Rails中Model关系在Migrate的体现
- 高通处理器一览表
- 在cmd里,如何用指令断开网络连接然后再恢复
- sharesharesdkQQ分享不成功,无法调起客户端
- 数据结构--链队
- 在linux下定时执行php网页
- MTK 三星处理器一览表
- 数学陶冶我一生(陈省身)
- MyEclipse 2015 stable 3.0 详解安装图解与破解、注册方法
- APP开发实战153-ANR异常的处理
- iOS之iOS9新特性——nonnull、nullable、null_resettable、_Null_unspecified
- shell数组
- 设计模式深入学习---Prototype原型模式