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

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

循環隊列

2019-11-10 18:34:56
字體:
來源:轉載
供稿:網友
#include <stdio.h>#include <malloc.h>//循環隊列 #define MAXSIZE 10typedef int sElemType;typedef struct queue{	sElemType data[MAXSIZE];	int front;	int rear;}queue; void init_queue(queue* q) {    q->front = 0;    q->rear = 0;} void in_queue(queue* q, sElemType e) {    if ((q->rear + 1) % MAXSIZE == q->front) {	    return;//隊列已滿 	}		q->data[q->rear] = e;	q->rear = (q->rear + 1) % MAXSIZE;}void out_queue(queue* q, sElemType* e) {    if (q->front == q->rear) {	    return;  //隊列為空 	}	*e = q->data[q->front];	q->front = (q->front + 1) % MAXSIZE;}int main() {		queue* q = (queue*)malloc(sizeof(queue));	init_queue(q);		for (int i = 0; i < MAXSIZE; i++) {	    in_queue(q, i);	}		sElemType e;	for (int i = 0; i < MAXSIZE - 1; i++) {	    out_queue(q, &e);	    PRintf("%d ", e);	}	    return 0;}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 东兰县| 台中县| 双柏县| 襄樊市| 镇雄县| 新乐市| 中牟县| 松桃| 银川市| 阜南县| 同仁县| 榆社县| 无棣县| 阿坝| 大埔区| 湖北省| 六盘水市| 黄山市| 靖西县| 玉门市| 徐水县| 岳西县| 黄山市| 正镶白旗| 焦作市| 伊宁市| 阿克陶县| 伊宁县| 蓬莱市| 侯马市| 上林县| 朝阳市| 曲阳县| 三门峡市| 涞水县| 二连浩特市| 中西区| 新兴县| 保康县| 天津市| 吐鲁番市|