【发布时间】:2020-09-09 18:02:29
【问题描述】:
我需要为汽车服务管理系统创建一个队列。该组织提供“普通”和“紧急”两种服务类型。优先考虑选择紧急选项的客户,因此比普通客户更早得到服务。这是我的代码,请随时提出任何问题,我要求您以开放的心态对待这个问题。感谢广告 ''' '
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;
}
}
} ' '''
【问题讨论】:
-
那么问题出在哪里?
-
两个队列的形成和优先级。我不知道我是否应该使用 2 个队列
-
我建议的第一件事是创建更多具有特定工作的功能。但最终我不知道你想做什么。您是否正在尝试实施某种模型/算法来为更高优先级的任务和更低优先级的任务提供服务?
-
是的,这正是我想要做的
-
这是您的实际代码吗?这不可能编译。