authorisation letter:一个用C++实现的队列问题

来源:百度文库 编辑:查人人中国名人网 时间:2024/05/09 03:17:38
一个循环队列问题(只在...中填程序,其他的不能改动,各位帮帮忙啊!)
// QueueDemo.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <stdio.h>
#define N 6

typedef struct{
char carID;
int arritime;
}car;

typedef struct{
car elem[N];
...;
}CycleQueue;

void initQueue(CycleQueue *s)
{
...
}

void InQueue(CycleQueue *s,car *x)
{
...
}

void OutQueue(CycleQueue *s,car *x)
{
...
}/**************************************************************/

int main(int argc, char* argv[])
{
CycleQueue myQueue;
car x,y;
//char b;
char c;
int choice=0;
int m=0;
//clrscr();
initQueue(&myQueue);
while(choice!=4)
{
printf("/****************/\n");
printf("1.In Queue\n");
printf("2.Out Queue\n");
printf("3.Print Out\n");
printf("4.Exit\n");
printf("Your selection:");
scanf("%d",&choice);
switch(choice)
{
case 1:

printf("please input the element that go into Queue:\n");
scanf("%s",&y.carID);x=y;
c = y.carID;
if((c>='a'&&c<='z') || (c>='A'&&c<='Z'))
{
if(...)
{
printf("there are no rooms in Queue now!:\n");
}
else
{
InQueue(&myQueue,&x);

printf("there are %d cars in Queue\n",...);
}
}
else
{
printf("/***************************************************/\n");
printf("Illegal input! Please inut a int value for car's number\n",N);
printf("/***************************************************/\n");
}
break;
case 2:
if(...)
{
printf("Error! there are no cars in Queue now! You cannot pop out cars!\n");
}
else
{
OutQueue(&myQueue,&x);
printf("the car %C get out from Queue\n",x.carID);
printf("there are %d cars in Queue\n",...);
}
break;
case 3:
m = ...;
if(...)
printf("There are %d cars in Queue as following:\n",m);
while(...)
{
printf("CarNo. %d, carID is %C\n",m,myQueue.elem[m].carID);
m--;
}
break;
case 4:
break;
}
}
return 0;
}