佇列是一種有序的線性表,佇列的兩端分別稱為隊首和隊尾。佇列只允許在隊尾進行插入操作,在隊首進行刪除操作。
插入元素稱為入隊,刪除元素稱為出隊。 佇列常用鍊錶或陣列來實現。
#include #include using namespace std;
#define max 1000
//佇列定義
struct element;
element queue[max];
int rear = 0;
int front = 0;
//判斷佇列是否為空
bool is_empty()
//判斷佇列是否已滿
bool is_full()
//入隊操作
void push(element item)
//出隊(刪除)操作
void pop()
//讀取隊首元素
element front1()
int main()
資料結構 佇列
一 佇列的迴圈陣列實現。1 初始化 空佇列。令rear front 0。2 入佇列 約定rear指向佇列尾元素的下乙個位置。入佇列時,先判斷佇列是否已滿,而後將array rear x 然後rear 3 出佇列 約定front指向佇列的首元素位置。出佇列時,先判斷佇列是否為空,而後返回隊首元素re ...
資料結構 佇列
資料參考自 資料結構c 語言描述 佇列是一種先進先出的資料結構,這與棧正好相反。下例是簡單的queue實現 queue.h檔案 ifndef queue h define queue h include include 資料元素結構 自定義 struct datatype 佇列元素最大數 const...
資料結構 佇列
code for fun created by dream whui 2015 1 25 include stdafx.h include include using namespace std define true 1 define false 0 define ok 1 define erro...