繁体   English   中英

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

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

我需要为汽车服务管理系统创建一个队列。 该组织提供“正常”和“紧急”两种服务类型。优先选择紧急选项的客户,因此比普通客户更早得到服务。 这是我的代码,请随时提出任何问题,我要求您以开放的心态接受这个问题。 感谢广告 ''' '

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;
    }
    }
    

} ''''

我需要为汽车服务管理系统创建一个队列。 该组织提供“正常”和“紧急”两种服务类型。优先选择紧急选项的客户,因此比普通客户更早得到服务。 这是我的代码,请随时提出任何问题,我要求您以开放的心态接受这个问题。 感谢广告 ''' '

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