C Language Learning: Using queues to implement a bank Queuing System

Source: Internet
Author: User

C Language Learning: Using queues to implement a bank Queuing System

 

This document uses queues to implement the bank queuing system. The above connection is implemented by the queue interface I implemented.

 

 

#include 
 
  #include 
  
   #include 
   
    #include seqQueue.hint 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);        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);        return -1;    }        data = queue_pop(queue);     printf(0x%x,data);    printf(please number is %d handles the service,data->number);}int menu(){    printf(********************);    printf(1.new consumer);    printf(2.next consumer);    printf(0.quit );    printf();    printf(********************);}int main(){    int opt = 0;    int len = 0;    DATATYPE_T data;    SEQQUEUE *queue=NULL;     queue = queue_init();    if(queue==NULL)    {        printf(creat queue failed);        return -1;    }    do    {        menu();        printf(please input select!);        scanf(%d,&opt);        switch(opt)        {            case 1:                add_queue(queue);                len = get_queue_length(queue);                printf(current wait for %d consumer,len);                break;            case 2:                next(queue);                len = get_queue_length(queue);                printf(current wait for %d consumer,len);                                break;            case 0:                break;            default:                break;        }    }while(opt!=0);        return 0;}
   
  
 

 

??

Related Article

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.