# Include <iostream> using namespace STD; # define OK 1 # define true 1 # define false 0 # define error 0 # define maxsize 10 typedef int status; // returned status value typedef int elemtype; // data type // data structure typedef struct queue_list {elemtype data [maxsize]; // The Int rear element in the queue; // int front coordinate of the element at the end; // coordinate of the element at the header} queue_list; // Initialize an empty queue status init_quelist (queue_list * l) {L-> front = 0; L-> rear = 0; Return OK;} // evaluate the queue length int length_quelist (queue_list L) {return (L. rear-L.front + maxsize) % maxsize; // length of the computing queue} // inbound queue operation status in_quelist (queue_list * l, elemtype E) {If (L-> rear + 1) % maxsize = L-> front) Return Error; L-> data [L-> rear] = E; l-> rear = (L-> rear + 1) % maxsize; // if the original rear is at the end of the array, move another bit to return OK before the array ;} // status ou_quelist (queue_list * l, elemtype & E) {If (L-> front = L-> rear) return error; E = L-> data [L-> front]; // if the original front is at the end of the array, move another one to the front of the array. L-> front + = 1; return OK;} int main () {system ("pause"); return 1 ;}
Big talk Data Structure-queue ordered Storage Structure