Parking lot management (there are still errors, hope to be modified by experts)

Source: Internet
Author: User


# Include <time. h>
# Include <stdio. h>

# Define MAX 10

Struct tm * timer;

Struct carnode {
Char number [5];/* the license plate number is 6 Characters */
Struct tm * intime, * outtime;
};

Struct carstack {
Struct carnode car [MAX];
Int base;
Int top;
Int M;/* M records the number of data in the next station */
} Carstack;

Struct QNode {/* queue contacts */
Struct carnode data;
Struct QNode * next;
};

Struct LinkQueue {
Struct QNode * front, * rear;
} LinkQueue;

 

Void initstack (struct carstack * S)/* apply for space for the sequential stack */
{
S-> base = (int) malloc (MAX * sizeof (struct carnode ));
If (! S-> base)
{Printf ("Stack initialization failed n ");
Exit (-1 );
}
S-> top = S-> base;
S-> M = 0;
Printf ("Stack initialization completed n ");
Getchar ();

}

Void initqueue (struct LinkQueue * Q)/* queue of the leading node */
{Struct QNode * p;
P = (struct QNode *) malloc (sizeof (struct QNode ));
Q-> front = Q-> rear = p;
If (! Q-> front) {printf ("queue initialization failed n ");
Exit (-1 );
}
Q-> front-> next = Q-> rear-> next = NULL;
Printf ("queue initialization completed n ");
Getchar ();
}

Void push (struct carstack * S, struct carnode new)
{
If (S-> M = MAX) printf ("stack overflow!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.