Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- typedef struct elem {
- char licensePlate[36];
- struct elem *urm;
- }node;
- node *root = NULL;
- node *ultim = NULL;
- node *create(char valoare[36]) {
- node *p;
- p = (node*)malloc(sizeof(node));
- strcpy(p->licensePlate, valoare);
- p->urm = NULL;
- return p;
- }
- node *add(node *nou) {
- nou->urm = root;
- root = nou;
- return root;
- }
- node *enterTheParking(char licensePlate[36]) {
- node *nou = create(licensePlate);
- if (root == NULL)
- {
- ultim = nou;
- }
- root = add(nou);
- }
- node *exitTheParking() {
- node *aux;
- if (root == NULL) {
- printf("The parking lot is empty!");
- return NULL;
- }
- else
- {
- aux = root;
- }
- root = root->urm;
- free(aux);
- }
- void showCars() {
- node *p;
- for (p = root; p!= NULL; p = p->urm) {
- printf("%s\n", p->licensePlate);
- }
- }
- int main()
- {
- enterTheParking("BH14CAP");
- enterTheParking("BH10BXD");
- enterTheParking("HD09LBO");
- showCars();
- exitTheParking();
- showCars();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement