if(!flag)
{
printf("No this car!!");
getch();
}
while(!StackEmpty(*temp))
{
Pop(temp,p);
Push(In,p);
}
free(p);
if(flag&&Wait->front!=Wait->rear) /*车站中有空位,便道有车,车入站*/
{
q=(QueueNode *)malloc(sizeof(QueueNode));
q=Wait->front->next;
t=q->data;
if(q!=NULL)
{
Push(In,t);
printf("\nThe ");
printf("%s",t->num);
printf(" car in part!");
printf("\nInput the time the car arrive(00:00): ");
scanf("%d:%d",&t->reach.hour,&t->leave.min);
}
Wait->front->next=q->next;
if(q==Wait->rear) Wait->rear=Wait->front;
free(q);
}
return 1;
}
/********************************************************************************/
void Print(SqStackCar *In,SqStackCar *Temp,LinkQueueCar *Wait) /*打印函数*/
{
int c=0;
int count=1;
CarNode *p,*t;
QueueNode *q;
q=(QueueNode *)malloc(sizeof(QueueNode));
p=(CarNode *)malloc(sizeof(CarNode));
t=(CarNode *)malloc(sizeof(CarNode));
while(1&&c!='3')
{
clrscr();
gotoxy(1,10);
printf("1. Print the road!");
gotoxy(1,11);
printf("2. Print the part!");
gotoxy(1,12);
printf("3. return.");
do{
printf("\nInput your choice:");
c = getche();
printf("\n");
}while(c!='1'&&c!='2'&&c!='3');
if(c=='2') /*打印停车场*/
{
printf("The car in the part!\n");
count=1;
while(!StackEmpty(*In))
{
Pop(In,t);
Push(Temp,t);
}
while(!StackEmpty(*Temp))
{
Pop(Temp,t);
printf("The ");
printf("%d",count);
printf(" car number is: ");
count++;
puts(t->num);
Push(In,t);
}
printf("Press any key to continue...");
getch();
}
if(c=='1') /*打印便道*/
{
printf("The car in the road!\n");
count=1;
q=Wait->front->next;
if(Wait->front!=Wait->rear) /**/
{
while(q!=NULL)
{
p=q->data;
printf("The ");
printf("%d",count);
printf(" Car number is: ");
puts(p->num);
q=q->next;
count++;
}
}
else printf("\nNo car in the road.");
printf("Press any key to continue...");
getch();
}
}
}
/***************************主程序***********************************************/
int Arrive(SqStackCar *In,LinkQueueCar *Wait);
int Departure(SqStackCar *In,SqStackCar *temp,LinkQueueCar *Wait);
void Print(SqStackCar *In,SqStackCar *temp,LinkQueueCar *Wait);
void initialization();
char readcommand();
void interpret(char cmd);
main()
{
char cmd;
SqStackCar part,temp;
LinkQueueCar road;
InitStack(&part);
InitStack(&temp);
InitQueue(&road);
printf("Press any key to continue......");
getch();
while(1)
{
initialization(); /*初始化界面*/
cmd = readcommand(); /*读取停车场状况*/
clrscr();
switch(cmd)
{
case 'a': Arrive(&part,&road); break;
case 'A': Arrive(&part,&road); break;
case 'd': Departure(&part,&temp,&road); break;
case 'D': Departure(&part,&temp,&road); break;
case 'p': Print(&part,&temp,&road); break;
case 'P': Print(&part,&temp,&road); break;
case 'e': printf("Press any to continue...");getch();exit(0); break;
case 'E': printf("Press any to continue...");getch();exit(0); break;
default : printf("ERROR!"); break;
}
}
}
/********************************************************************************/
void initialization() /*初始函数*/
{
int i;
clrscr();
gotoxy(0,0);
for(i=1;i<=240;i++)
printf("\1");
gotoxy(15,8);
printf("THIS IS A CAR PART MANAGE SYSYTEM!");
gotoxy(15,12);
printf("NAME: LIYONGJUN.");
gotoxy(15,13);
printf("NUM: 3104006893.");
gotoxy(15,14);
printf("GRADE: 2004.");
gotoxy(15,15);
printf("CLASS: COMPUTER SCIENCE AND TECHNOLOGY 10");
gotoxy(1,20);
printf("\n********************************************************************************");
printf("1. Car Arrive--A 2. Car Departure--D 3. Print Car--P 4.Exit--E");
printf("\n********************************************************************************");
printf("Input C,D,P,E choose!!\n");
}
char readcommand() /*选择函数*/
{
char cmd;
do{
printf("Input your choice:");
cmd = getche();
printf("\n");
}while((cmd!='a')&&(cmd!='A')&&(cmd!='d')&&(cmd!='D')&&(cmd!='p')&&(cmd!='P')&&(cmd!='E')&&(cmd!='e'));
return cmd;
}
上一页 [1] [2]
数据结构课程设计-C语言停车场管理器 第2页下载如图片无法显示或论文不完整,请联系qq752018766