国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

隊列的鏈式存儲結構

2019-11-09 20:49:51
字體:
來源:轉載
供稿:網友
/*    IDE: Dev-C++ 5.11    GCC-version: 4.9.2 64-bit*/#include <stdio.h>#include <malloc.h>typedef int sElemType;typedef struct node {	sElemType e;	node* next;} NODE;typedef struct queue {	int lenght;	NODE* front;	NODE* rear;} queue;NODE* create_node(sElemType e) {	NODE* n = (NODE*) malloc(sizeof(NODE));	n->e = e;	n->next = NULL;}void init_queue(queue* q, sElemType num) {	q->lenght = 0;	q->front = create_node(num);	q->front->next = create_node(num);	q->rear = q->front->next;}void in_queue(queue* q, sElemType e) {	q->lenght++;	q->rear->e = e;	q->rear->next = create_node(0);	q->rear = q->rear->next;}bool out_queue(queue* q, sElemType* e) {	if (q->front == q->rear) {		return false;	}	q->lenght--;	*e = q->front->e;	NODE* p = q->front;	q->front = q->front->next;	free(p);	return true;}int main() {	queue* q = (queue*) malloc(sizeof(queue));	init_queue(q, 0);	in_queue(q, 1);	in_queue(q, 2);	in_queue(q, 3);	q->front = q->front->next;		PRintf("%d/n", q->lenght);    sElemType e;	while (out_queue(q, &e)) {	    printf("%d ", e);	}	return 0;}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 邯郸县| 河西区| 长沙市| 台江县| 舒兰市| 洛川县| 丹阳市| 肇庆市| 新乐市| 永泰县| 桃源县| 鄂尔多斯市| 漯河市| 蕲春县| 寻乌县| 望奎县| 阳曲县| 乌苏市| 丰都县| 大英县| 固始县| 喀喇沁旗| 吉木萨尔县| 甘南县| 宜良县| 蓬安县| 宜兰市| 图们市| 洛川县| 蒲城县| 嘉义市| 织金县| 陕西省| 聂拉木县| 新民市| 潢川县| 德阳市| 余江县| 容城县| 遂昌县| 遂平县|