Algorithm-Data Structure-queue-general Linux technology-Linux programming and kernel information. The following is a detailed description. /*************************************** ******************
Title: queue. c
Author: zhanglong
Time: 200508
**************************************** ******************/
/* ===================== Function declaration ============================== = */
Void queue_init (QUEUE * s );
Void queue_add (QUEUE * s, int data );
Int queue_remove (QUEUE * s );
Int queue_count (QUEUE * s );
Void queue_free (QUEUE * s );
/* --------------- Queue free ----------------*/
Void queue_free (QUEUE * s)
{
While (queue_count (s )){
Queue_remove (s );
}
}
/* =============== Main function ========= */
Int main (int argc, char * argv [])
{
QUEUE * s;
S = (QUEUE *) AC_MALLOC (sizeof (QUEUE ));
Int I;
Queue_init (s );
For (I = 0; I <100; I + = 3 ){
Queue_add (s, I );
}
Printf ("queue count is % d \ n", queue_count (s ));
Queue_remove (s );
Printf ("queue count is % d \ n", queue_count (s ));
Queue_remove (s );
Printf ("queue count is % d \ n", queue_count (s ));
Queue_remove (s );
Printf ("queue count is % d \ n", queue_count (s ));
Printf ("queue head is % d \ n", s-> head-> data );
Printf ("queue tail is % d \ n", s-> tail-> data );
Queue_free (s );
Printf ("queue count is % d \ n", queue_count (s ));
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