Parking lot Program Design

Source: Internet
Author: User
Tags define null
Problem description: due to the rapid economic development in China, vehicle ownership has also increased sharply, and traffic congestion is becoming more and more serious. Parking lots are becoming a scarce resource, therefore, there is a need for efficient use of parking lots. Billing is an effective way to control scarce resources. The parking lot is billed for free within 1 hour. More than 1 hour, 6 hours

Problem description: due to the rapid economic development in China, vehicle ownership has also increased sharply, and traffic congestion is becoming more and more serious. Parking lots are becoming a scarce resource, therefore, there is a need for efficient use of parking lots. Billing is an effective way to control scarce resources. The parking lot is billed for free within 1 hour. More than 1 hour, 6 hours

Problem description:

As China's economy is developing rapidly, the amount of vehicle ownership has also increased significantly, and the congestion in cities is getting worse and worse. Parking lots are becoming a scarce resource, so there is a need for efficient use of parking lots.
Billing is an effective way to control scarce resources. The parking lot is billed for free within 1 hour. More than 1 hour, 6 yuan per hour. Manual billing is time-and labor-consuming and error-prone. I hope you can develop a software to help hard-working security guards manage parking lots.

1) Manage parking spaces:
Query the total number of parking spaces
How many empty parking spaces can be queried
Query the license plate number and parking time of the occupied parking space
2) billing management:
You can query the number of parked vehicles.
Able to record the parking time of a vehicle
Calculate the fee based on the stopped time

The Code is as follows:

# Include
 
  
# Include
  
   
# Include
   
    
# Include
    
     
# Define NULL 0 # define LEN sizeof (struct node) struct node {int num; // serial number char numble [47]; // plate number char intime [47]; // entry time char outtime [47]; // departure time struct node * next;}; struct node * creat () // create a parking list with ten parking spaces {int n; struct node * head, * p, * tail; head = NULL; for (n = 1; n <= 10; n ++) {p = (struct node *) malloc (LEN); p-> num = n; strcpy (p-> numble, "0"); strcpy (p-> intime, "0"); strcpy (p-> outtime, "0"); if (n = 1) {head = p ;} Elsetail-> next = p; tail = p;} tail-> next = NULL; return (head);} void print (struct node * head) {struct node * p; printf ("current parking lot information: \ n"); p = head; if (head! = NULL) {do {printf ("yard no.: %-6d license plate number: % 5s \ n", p-> num, p-> numble ); printf ("entry time: % 32s \ n", p-> intime); printf ("departure time: % 32s \ n", p-> outtime ); printf ("************************************* * ***** \ n "); p = p-> next;} while (p! = NULL) ;}} void Money (struct node * head) // billing {int n, m; struct node * p; time_t rawtime; struct tm * timeinfo; time (& rawtime); timeinfo = localtime (& rawtime); printf ("dear, enter the vehicle number you want to pay \ n"); scanf ("% d ", & n); p = head; while (p-> num! = N) {p = p-> next; // find the corresponding serial number} // int tt = asctime (timeinfo)-p-> intime; char time1 [47], time2 [47]; strcpy (time1, asctime (timeinfo); strcpy (time2, p-> intime); int len1 = strlen (time1 ); int len2 = strlen (time2); int t1 = 0, t2 = 0; for (int I = 0; I <len1; I ++) {if (time1 [I] = ':') {t1 = t1 * 10 + time1 [I-2]-'0' ;}} for (I = 0; I <len2; I ++) {if (time2 [I] = ':') {t2 = t2 * 10 + time2 [I-2]-'0 ';}} int tt = t2-t1; if (tt> 1) m = (TT-1) * 6; elsem = 0; printf ("total parking fee: % d \ n", m);} void in (struct node * head) // The vehicle enters the parking lot {char s [47]; time_t rawtime; struct tm * timeinfo; time (& rawtime); timeinfo = localtime (& rawtime); struct node * p; p = head; while (p! = NULL) & (strcmp (p-> numble, "0 ")! = 0) // find the empty parking space {p = p-> next;} if (p! = NULL) {printf ("Enter the current license plate number! \ N "); scanf (" % s ", s); printf (" your parking space is: [% d! \ N ", p-> num); strcpy (p-> numble, s); strcpy (p-> intime, asctime (timeinfo ));} else {printf ("the parking lot is full. Please exit! \ N ") ;}} void out (struct node * head) {struct node * p; int n; time_t rawtime; struct tm * timeinfo; time (& rawtime ); timeinfo = localtime (& rawtime); printf ("Enter the vehicle serial number! \ N "); scanf (" % d ", & n); p = head; while (p-> num! = N) {p = p-> next; // find the corresponding serial number} strcpy (p-> outtime, asctime (timeinfo); printf ("the license plate number is: [% s] \ n ", p-> numble); printf (" vehicle entry time: % s \ n ", p-> intime ); printf ("Vehicle departure time: % s \ n", p-> outtime); strcpy (p-> numble, "0"); strcpy (p-> intime, "0") ;}void main () {int n; struct node * head; head = NULL; printf ("enter a number to operate \ n "); printf ("0: Exit program \ n"); printf ("1: Create parking lot information \ n"); printf ("2: Output parking lot information \ n "); printf ("3: the vehicle enters the parking lot \ n"); printf ("4: The vehicle leaves the parking lot \ n"); printf ("5: Vehicle parking fee \ n "); printf (" enter a number to operate \ n "); scanf (" % d ", & n); while (n! = 0) {switch (n) {case 1: head = creat (); break; case 2: print (head); break; case 3: in (head); break; case 4: out (head); break; case 5: Money (head); break; default: 0;} printf ("enter a number, perform operations \ n "); scanf (" % d ", & n );}}
    
   
  
 

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.