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

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

隊列的鏈式存儲結構

2019-11-09 20:38:03
字體:
來源:轉載
供稿:網友
/*    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;}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 平南县| 肥西县| 涿鹿县| 长沙县| 扶沟县| 崇州市| 隆昌县| 阳西县| 山东| 庄河市| 建平县| 亳州市| 灌南县| 周口市| 九龙城区| 大姚县| 安康市| 河池市| 瑞金市| 固阳县| 桂林市| 历史| 淮滨县| 六枝特区| 龙江县| 新建县| 湘潭县| 永仁县| 庆安县| 本溪市| 白水县| 高州市| 华安县| 阿尔山市| 鹤岗市| 化德县| 思茅市| 龙门县| 九江市| 南宫市| 吉木乃县|