简体   繁体   English

我怎样才能更好地使用 c 实现这个队列?

[英]How can I better implement this queue using c?

I need to create a queue for a car service management system.我需要为汽车服务管理系统创建一个队列。 The organisation offers two service types "Normal" and "Urgent".Priority is given to the clients who choose the urgent option and thus, are served earlier than the normal clients.该组织提供“正常”和“紧急”两种服务类型。优先选择紧急选项的客户,因此比普通客户更早得到服务。 This is my code, please feel free to ask any questions and I ask that you take this question with an open mind.这是我的代码,请随时提出任何问题,我要求您以开放的心态接受这个问题。 Thanks in adv ''' '感谢广告 ''' '

struct node *normal= NULL;
struct node *urgent= NULL;

void queueRegistration()
{
    /*Print Menu to user */
    char urgency;




    int choice;

    char *service;
    char *serviceType;

    /*Queue cutting menu*/

    system("cls");
    gotoxy(50,1);
    printf("================================");
    gotoxy(50, 2);
    printf("QUEUE REGISTRATION");
    gotoxy(50, 3);
    printf("================================\n");
    gotoxy(50, 4);
    printf("We offer urgent and Normal prices, service prices depend on 
    the urgency\n");
    gotoxy(50, 6);
    printf("1.Normal price\n");
    gotoxy(50, 7);
    printf("2.Urgent price\n");
    gotoxy(50, 8);
    printf("Pick an option number from the list[1 or 2]: \n");
    gotoxy(50, 9);
    scanf("%d",& choice);

    time_t t = time(NULL);
    struct tm *tm = localtime(&t);
    int s[64];
    assert(strftime(s, sizeof(s), "%c", tm));
    int DATE ;
    DATE = s;
    return 0;

    if(choice==1)
    {
    struct node *temp,*ptr;
    temp=(struct node *)malloc(sizeof(struct node));
    if(temp==NULL){
    printf("\nOut of Memory Space:\n");
    return;
    }
    printf("\nEnter Name:\t" );
    scanf("%s",&temp->name );
    printf("\nEnter Car Number Plate:\t" );
    scanf("%s",&temp->plateNumber );

    temp->next =NULL;
    if(normal==NULL)
    {
                  normal=temp;
    }
    else
    {
    ptr=normal;
    while(ptr->next !=NULL){
    ptr=ptr->next ;
    }
    ptr->next =temp;
    }

    }
    else if(choice==2)
    {
    struct node *temp,*ptr;
    temp=(struct node *)malloc(sizeof(struct node));
    if(temp==NULL){
    printf("\nOut of Memory Space:\n");
    return;}

    printf("\nEnter Name:\t" );
    scanf("%s",&temp->name );

    printf("\nEnter Car Number Plate:\t" );
    scanf("%s",&temp->plateNumber );

    temp->next =NULL;
    if(urgent==NULL)
    {
    urgent=temp;}

    else{
    ptr=urgent;
    while(ptr->next !=NULL){
    ptr=ptr->next ;
    }
    ptr->next =temp;
    }
    }
    

} ' ''' } ''''

I need to create a queue for a car service management system.我需要为汽车服务管理系统创建一个队列。 The organisation offers two service types "Normal" and "Urgent".Priority is given to the clients who choose the urgent option and thus, are served earlier than the normal clients.该组织提供“正常”和“紧急”两种服务类型。优先选择紧急选项的客户,因此比普通客户更早得到服务。 This is my code, please feel free to ask any questions and I ask that you take this question with an open mind.这是我的代码,请随时提出任何问题,我要求您以开放的心态接受这个问题。 Thanks in adv ''' '感谢广告 ''' '

struct node *normal= NULL;
struct node *urgent= NULL;

void queueRegistration()
{
    /*Print Menu to user */
    char urgency;




    int choice;

    char *service;
    char *serviceType;

    /*Queue cutting menu*/

    system("cls");
    gotoxy(50,1);
    printf("================================");
    gotoxy(50, 2);
    printf("QUEUE REGISTRATION");
    gotoxy(50, 3);
    printf("================================\n");
    gotoxy(50, 4);
    printf("We offer urgent and Normal prices, service prices depend on 
    the urgency\n");
    gotoxy(50, 6);
    printf("1.Normal price\n");
    gotoxy(50, 7);
    printf("2.Urgent price\n");
    gotoxy(50, 8);
    printf("Pick an option number from the list[1 or 2]: \n");
    gotoxy(50, 9);
    scanf("%d",& choice);

    time_t t = time(NULL);
    struct tm *tm = localtime(&t);
    int s[64];
    assert(strftime(s, sizeof(s), "%c", tm));
    int DATE ;
    DATE = s;
    return 0;

    if(choice==1)
    {
    struct node *temp,*ptr;
    temp=(struct node *)malloc(sizeof(struct node));
    if(temp==NULL){
    printf("\nOut of Memory Space:\n");
    return;
    }
    printf("\nEnter Name:\t" );
    scanf("%s",&temp->name );
    printf("\nEnter Car Number Plate:\t" );
    scanf("%s",&temp->plateNumber );

    temp->next =NULL;
    if(normal==NULL)
    {
                  normal=temp;
    }
    else
    {
    ptr=normal;
    while(ptr->next !=NULL){
    ptr=ptr->next ;
    }
    ptr->next =temp;
    }

    }
    else if(choice==2)
    {
    struct node *temp,*ptr;
    temp=(struct node *)malloc(sizeof(struct node));
    if(temp==NULL){
    printf("\nOut of Memory Space:\n");
    return;}

    printf("\nEnter Name:\t" );
    scanf("%s",&temp->name );

    printf("\nEnter Car Number Plate:\t" );
    scanf("%s",&temp->plateNumber );

    temp->next =NULL;
    if(urgent==NULL)
    {
    urgent=temp;}

    else{
    ptr=urgent;
    while(ptr->next !=NULL){
    ptr=ptr->next ;
    }
    ptr->next =temp;
    }
    }
    

} ' ''' } ''''

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM