补充程序
#include<stdio.h>#define MAX 100
#define STACK_INIT_SIZE 100
typedef
typedef struct{
SElemType *base;
SElemType *top;
int stacksize;
}SeqStackCar;
typedef struct time
{
int hour;
int min;
}Time;
typedef struct node
{
Time reach;
Time leave;
}CarNode;
typedef struct NODE
{
CarNode *a[MAX-1];
int top;
}SeqStackCar,
typedef struct car
{
CarNode *data;
struct car *next;
}QueueNode;
typedef struct Node
{
QueueNode *head;
QueueNode *rear;
}LinkQueueCar;
Status InitStack(SeqStackCar &S){
//构造一个空栈//
S.base=(SElemType *)malloc(STACK_INIT_SIZE*sizeof(SElemType));
if(S.base) exit(OVERFLOW); //存储分配失败//
S.base=S.top;
S.stacksize=STACK_INIT_SIZE;
return OK;
}//InitStack
int Arrival(SeqStackCar *Enter,LingQueueCar *B){
CarNode *p;
QueueNode *t;
p=(CarNode *)malloc(sizeof(CarNode));
printf("请输入进入车辆的车牌号码:\n");
gets(p.num);
if(Enter.top<MAX){
Enter.top++;
printf("\n车辆在停车场的第%d个位置",Enter.top);
printf("\n车辆进入时间:")
scanf("%d:%d",&(p.reach.hour),&(p.reach.min));
Enter.a[Enter.top]=p;
}
else{
printf("车库已满!请将车辆停在便道上;");
t=(QueueNode *)malloc(sizeof(QueueNode));
t=p;
t.next=NULL;
B.rear.next=t;
B.rear=t;
return OK;
}
}
int Leave(SeqStackCar *Enter,SeqStackCar *Z,LingQueueCar *B,SeqStackCar *L){
int i=0,j=0;
printf("\n请输入离开车辆的位置号:");
scanf("%d",&i);
j=Enter.top;
for(j>i;j--){
Z.a[Z.top]=Enter.a[j];
Z.top++;
Enter.top--;
}
if(B.head!=NUll){
if(i=1){
Enter.a[Enter.top]=B.head.data;
}
else{
Enter.a[Enter.top]=B.head.data;
}
}
else{
while(Z.top>0){
Enter.a[Enter.top]=Z.a[Z.top];
Enter.top++;
Z.top--;
}
}
CarNode *p;
p=(CarNode *)malloc(sizeof(CarNode));
p=Enter.a[i-1];
printf("\n此车的离开时间为:");
scanf("%d:%d",&(p.leave.hour),&(p.leave.min));
printf("应缴纳的费用为:");
p.money=0.01*(60*(p.leave.hour-p.reach.hour)+p.leave.min-p.reach.min);
scanf("%f",&(p.money));
j=0;
if(L.top<MAX){
L.a[L.top].number=i;
L.a[L.top]=p;
L.top++;
}
}
void Seach(SeqStackCar *Enter,SeqStackCar *Z,LinkQueueCar *B){
int i=0,j=0;
printf("请输入需要查询车辆的位置:");
scanf("%d",&i);
if(Enter.a[i-1].leave.hour!=NULL){
printf("车辆未离开:\n");
printf(" 位置 到达时间\n");
printf(" %d %d:%d %f",i,Enter.a[i-1].reach.hour,Enter.a[i-1].reach.min,Enter.a[i-1].money);
}
else{
for(j=0;j<MAX;j++)
if(L.a[j].number==i){
printf("车辆已经离开\n");
printf(" 到达时间 离开时间 费用\n");
printf(" %d:%d %d:%d %f ",Enter.a[i-1].reach.hour,Enter.a[i-1].reach.min,Enter.a[i-1].leave.houe,Enter.a[i-1].leave.min,Enter.a[i-1].money);
}
}
}
void main(){
int i,
SeqStackCar *Enter;
SeqStackCar *Z;
SeqStackCar *L;
InitStack(Enter);
InitStack(Z);
InitStack(B);
LinkQueueCar *B;
InitQueue(B);
for(i=0;i++){
printf("1.车辆进入登记 2.车辆离开登记 3.车辆信息查询 4.退出系统");
scanf("%d",&i);
switch(i)
{
case 1:
Arrival(Enter,B);break;
case 2:
Leave(Enter,Z,B,L);break;
case 3:
Seach(Enter,Z,B);break;
case 4:
exit(0);
}
}
}
只求有人能不从这个程序,,明天交作业了,,急啊!