Big talk Data Structure-queue ordered Storage Structure

Source: Internet
Author: User

 

 
# 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.