#include<stdio.h>
#include<stdlib.h>
#include <time.h>
#include<conio.h>
static int i = 1;
void date();
void CustomerReview();
typedef struct QNode
{
int bianhao;//队内成员取到的号码
struct QNode* next;
}QNode, * QueuePtr;
typedef struct
{
QueuePtr front;//队头指针
QueuePtr rear;//队尾指针
}Queue;//创建链式队列
void initQueue(Queue* q)//队列的初始化
{
q->front = q->rear = (QNode*)malloc(sizeof(QNode));
if (!q->front)//初始化失败退出
{
return;
}
q->front->next = NULL;
}
Queue s1, s2, s3;//创建三个队列窗口
int shows1()//显示1窗口人员
{
QNode* p = (QNode*)malloc(sizeof(QNode));
if (s1.front == s1.rear)
{//队列为空队列
printf("当前无排队人员 *\n");
return 0;
}
p = s1.front->next;
while (p)
{
printf("%d ", p->bianhao);
p = p->next;
}
printf("\n");
}
int shows2()//显示2窗口人员
{
QNode* p = (QNode*)malloc(sizeof(QNode));
if (s2.front == s2.rear)
{//队列为空队列
printf("当前无排队人员 *\n");
return 0;
}
p = s2.front->next;
while (p)
{
printf("%d ", p->bianhao);
p = p->next;
}
printf("\n");
}
int shows3()//显示3窗口人员
{
QNode* p = (QNode*)malloc(sizeof(QNode));
if (s3.front == s3.rear)
{//队列为空队列
printf("当前无排队人员 *\n");
return 0;
}
p = s3.front->next;
while (p)
{
printf("%d ", p->bianhao);
p = p->next;
}
printf("\n");
}
void show()//总显示窗口
{
printf("\n\t\t\t\t\t*1号窗口排队人员:");
shows1();
printf("\n\t\t\t\t\t*2号窗口排队人员:");
shows2();
printf("\n\t\t\t\t\t*3号窗口排队人员:");
shows3();
printf("\t\t\t\t\t");
system("pause");
}
void EnQueue1(Queue* q, int i)//队列插入
{
QNode* p = (QNode*)malloc(sizeof(QNode));
p->bianhao = i;
p->next = NULL;
q->rear->next = p;
q->rear = p;
}
int DeQueue(Queue* q, int e)//队列删除
{
if (q->front == q->rear)
{//队列为空队列
return 1;
}
QNode* p = (QNode*)malloc(sizeof(QNode));
p = q->front->next;
e = p->bianhao;
q->front->next = p->next;
if (q->rear == p)
{
q->rear = q->front;
}
free(p);
}
void EnQueue()//选择窗口插入
{
show();
printf("\t\t\t\t\t*********************************\n");
printf("\t\t\t\t\t*请选择窗口服务:\t\t*\n");
printf("\t\t\t\t\t*\t 1.1号窗口 *\n");
printf("\t\t\t\t\t*\t 2.2号窗口 *\n");
printf("\t\t\t\t\t*\t 3.3号窗口 *\n");
printf("\t\t\t\t\t*********************************\n");
int a;
printf("\t\t\t\t\t");
scanf_s("%d", &a);
switch (a)
{
case 1:
{
EnQueue1(&s1, i);
printf("\t\t\t\t\t*取号成功,你是1号窗口%d号,请等待办理*\n\t\t\t\t\t", i);
i++;
break;
}
case 2:
{
EnQueue1(&s2, i);
printf("\t\t\t\t\t*取号成功,你是2号窗口%d号,请等待办理*\n\t\t\t\t\t", i);
i++;
break;
}
case 3:
{
EnQueue1(&s3, i);
printf("\t\t\t\t\t*取号成功,你是3号窗口%d号,请等待办理*\n\t\t\t\t\t", i);
i++;
break;
}
default:
{
printf("\t\t\t\t\t* 无效窗口 *\n\t\t\t\t\t\n");
printf("\t\t\t\t\t* ");
break;
}
}
system("pause");
system("cls");
}
void vip1(Queue* q, int i)//vip头插
{
QNode* p = (QNode*)malloc(sizeof(QNode));
if (q->front == q->rear)
{
p->bianhao = i;
p->next = NULL;
q->rear->next = p;
q->rear = p;
}
else
{
p->bianhao = i;
p->next = q->front->next;
q->front->next = p;
}
}
void vip2()//vip插队
{
printf("\t\t\t\t\t*********************************\n");
printf("\t\t\t\t\t*请选择窗口服务:\t\t*\n");
printf("\t\t\t\t\t*\t 1.1号窗口 *\n");
printf("\t\t\t\t\t*\t 2.2号窗口 *\n");
printf("\t\t\t\t\t*\t 3.3号窗口 *\n");
printf("\t\t\t\t\t*********************************\n");
int a;
printf("\t\t\t\t\t");
scanf_s("%d", &a);
switch (a)
{
case 1:
{
vip1(&s1, i);
printf("\t\t\t\t\t*取号成功,你是1号窗口%d号,请等待办理*\n\t\t\t\t\t", i);
i++;
break;
}
case 2:
{
vip1(&s2, i);
printf("\t\t\t\t\t*取号成功,你是2号窗口%d号,请等待办理*\n\t\t\t\t\t", i);
i++;
break;
}
case 3:
{
vip1(&s3, i);
printf("\t\t\t\t\t*取号成功,你是3号窗口%d号,请等待办理*\n\t\t\t\t\t", i);
i++;
break;
}
default:
{
printf("\t\t\t\t\t* 无效窗口 *\n\t\t\t\t\t\n");
printf("\t\t\t\t\t* ");
break;
}
}
system("pause");
system("cls");
}
int CallNum(Queue* q)//查找/叫号功能
{
printf("\t\t\t\t\t* 请输入所取的号码:");
int a;
int b = 1;
scanf_s("%d", &a);
QNode* p = q->front->next;
while (p && p->bianhao != a)
{
p = p->next;
b++;
}
if (p == NULL || p->bianhao != a)
{
printf("\t\t\t\t\t* 对不起,您输入的号码不存在! *\n");
printf("\t\t\t\t\t");
system("pause");
return 1;
}
if (b == 1)
{
printf("\t\t\t\t\t*\t 你现在是第1位! \t*\n");
int e = 0;
DeQueue(q, e);
printf("\t\t\t\t\t*\t 办理完成! \t*\n");
CustomerReview();
}
if (b != 1 && (p != NULL || p->bianhao == a))
{
printf("\t\t\t\t\t* 你现在是第%d位,请等候谢谢! *\n", b);
printf("\t\t\t\t\t");
system("pause");
}
return 1;
}
void CounterServer()//柜员
{
printf("\t\t\t\t\t* 柜员您好,请输入您的服务窗口:*\n");
printf("\t\t\t\t\t*********************************\n");
printf("\t\t\t\t\t*\t 1.1号窗口 *\n");
printf("\t\t\t\t\t*\t 2.2号窗口 *\n");
printf("\t\t\t\t\t*\t 3.3号窗口 *\n");
printf("\t\t\t\t\t*********************************\n");
int a;
printf("\t\t\t\t\t");
scanf_s("%d", &a);
switch (a)
{
case 1:
{
printf("\t\t\t\t\t*\t1号窗口:");
shows1();
CallNum(&s1);
break;
}
case 2:
{
printf("\t\t\t\t\t*\t2号窗口:");
shows2();
CallNum(&s2);
break;
}
case 3:
{
printf("\t\t\t\t\t*\t3号窗口:");
shows3();
CallNum(&s3);
break;
}
default:
{
printf("\t\t\t\t\t*\t 无效柜号 \t\t*\n\t\t\t\t\t\n");
printf("\t\t\t\t\t* ");
system("pause");
system("cls");
break;
}
}
}
void CustomerReview()
{
printf("\n\t\t\t\t\t*********************************\n");
printf("\t\t\t\t\t*\t请对本次服务做出评价\t*\n");
printf("\t\t\t\t\t*\t1.非常满意!\t\t*\n");
printf("\t\t\t\t\t*\t2.比较满意!\t\t*\n");
printf("\t\t\t\t\t*\t3.一般!\t\t*\n");
printf("\t\t\t\t\t*\t4.不满意!\t\t*\n");
printf("\t\t\t\t\t*********************************\n");
int a;
printf("\t\t\t\t\t");
scanf_s("%d", &a);
while (a < 1 || a > 4)
{
printf("\t\t\t\t\t* 您的输入不正确,请重新输入: ");
scanf_s("%d", &a);
}
switch (a)
{
case 1:
case 2:
case 3:
case 4:
{
printf("\t\t\t\t\t* 非常感谢你的评价!谢谢! *\n");
printf("\t\t\t\t\t*\t");
system("pause");
system("cls");
break;
}
default:break;
}
}
void esc()
{
exit(0);
}
void menu()
{
date();
printf("\n\n\n\n\n\n\n\n\n");
printf("\t\t\t\t\t*********************************\n");
printf("\t\t\t\t\t***********银行排队系统**********\n");
printf("\t\t\t\t\t*********************************\n");
printf("\t\t\t\t\t*\t请选择服务:\t\t*\n");
printf("\t\t\t\t\t*\t1.普通用户排队\t\t*\n");
printf("\t\t\t\t\t*\t2.vip用户通道\t\t*\n");
printf("\t\t\t\t\t*\t3.显示各窗口等待人数\t*\n");
printf("\t\t\t\t\t*\t4.柜员服务界面\t\t*\n");
printf("\t\t\t\t\t*\t0.退出系统\t\t*\n");
printf("\t\t\t\t\t*********************************\n");
int a;
printf("\t\t\t\t\t");
scanf_s("%d", &a);
switch (a)
{
case 1:
{
system("cls");
date();
printf("\t\t\t\t\t*\t1.普通用户排队\t\t*\n");
EnQueue();
break;
}
case 2:
{
system("cls");
date();
printf("\t\t\t\t\t*\t2.vip用户通道\t\t*\n");
vip2();
break;
}
case 3:
{
system("cls");
date();
printf("\t\t\t\t\t*\t3.显示各窗口等待人数\t*\n");
show();
system("cls");
break;
}
case 4:
{
system("cls");
date();
printf("\t\t\t\t\t*\t4.柜员服务界面\t\t*\n");
CounterServer();
system("cls");
break;
}
case 0:
{
esc();
break;
}
default:
{
printf("\t\t\t\t\t*\t 服务项输入有误 \t*\n");
printf("\t\t\t\t\t*\t");
system("pause");
system("cls");
break;
}
}
}
void date()
{
time_t rawtime;
struct tm timeinfo;
char buffer[128];
time(&rawtime);
localtime_s(&timeinfo, &rawtime);
strftime(buffer, sizeof(buffer), "%Y/%m/%d %H:%M:%S", &timeinfo);
puts(buffer);
}
int main()//
{
system("color 0b");
static int i = 1;
initQueue(&s1);
initQueue(&s2);
initQueue(&s3);
while (1)
{
menu();
}
}
@FishC保持该代码所有功能不变将其改为c++语言 |