C Language Learning Queue Realization Bank queuing system

Source: Internet
Author: User


interface for queue operations: http://blog.csdn.net/qlx846852708/article/details/43666927

Data structure C language implementation: Http://blog.csdn.net/qlx846852708?viewmode=contents


This file is a queue implementation of the Bank queuing system, the above connection is my implementation of the queue interface implementation.


#include <stdio.h> #include <stdlib.h> #include <string.h> #include "seqQueue.h" int g_number = 0;int    Add_queue (Seqqueue *queue) {int ret = 0;    int number = 0;        datatype_t data;    ret = queue_full (queue);        if (ret==0) {data.number = ++g_number;        Data.time = time (NULL);    Queue_push (Queue,data);        } else {printf ("line up too much,please waiting\n");    return-1; } return 0;}    void Next (Seqqueue *queue) {int ret = 0;    datatype_t *data;    ret = queue_empty (queue);        if (ret) {printf ("The queue is empty\n");    return-1;     } data = Queue_pop (queue);    printf ("0x%x\n", data); printf ("Please number is%d handles the service\n", Data->number);}    int menu () {printf ("********************\n");    printf ("1.new consumer\n");    printf ("2.next consumer\n");    printf ("0.quit");    printf ("\ n"); printf ("********************\n");}    int main () {int opt = 0;    int len = 0; datatype_tData     Seqqueue *queue=null;    Queue = Queue_init ();        if (queue==null) {printf ("creat queue failed\n");    return-1;        } do {menu ();        printf ("Please input select!\n");        scanf ("%d", &opt);                Switch (opt) {case 1:add_queue (queue);                Len = get_queue_length (queue);                printf ("Current wait for%d consumer\n", Len);            Break                Case 2:next (queue);                Len = get_queue_length (queue);                                printf ("Current wait for%d consumer\n", Len);            Break            Case 0:break;        Default:break;        }}while (opt!=0); return 0;}



C Language Learning Queue Realization Bank queuing system

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.