簡體   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