【发布时间】:2018-01-20 08:18:33
【问题描述】:
我想在银行创建两个普通客户和贵宾客户队列, 1.如何在一个程序中创建两个队列。 2.如何将队列的结构作为函数入队和出队的参数传递? 我正在根据客户类型进行查询,例如 如果客户端是 vip,我会加入 queue1 如果客户端是普通的,我会加入 queue2 出队也一样
#include <stdio.h>
#include <malloc.h>
#include<string.h>
int position=0;
int length=1;enter code here
typedef struct Node
{
int record;
int CardNum;
char CustomerType[20];
struct Node* next;
}Node;
//VIP QUEUE
typedef struct queue
{
Node* front1 = NULL;
Node* rear1 = NULL;
}Queue1;
//Ordinary QUEUE
typedef struct queue
{
Node* front2 = NULL;
Node* rear2 = NULL;
}Queue2;
void Enqueue();
void Dequeue();
int main()
{
char command[10];
while(scanf("%s",command))
{
if(strcmp(command,"IN") == 0)
{
printf("IN:");
Enqueue();
}
if(strcmp(command,"LIST") == 0)
{
printf("LIST:\n");
List();
}
if(strcmp(command,"OUT") == 0)
{
Dequeue();
}
if(strcmp(command,"QUIT") ==0)
{
printf("GOOD BYE!\n");
break;
}
}
return 0;
}
【问题讨论】:
-
您尝试了什么,遇到了什么问题?另外,为什么队列需要两种不同的类型?它们应该是相同的类型,因为没有区别。