Home > Back-end >  Hope that they can help me to change the program, bosses do a c garage management system, but the in
Hope that they can help me to change the program, bosses do a c garage management system, but the in

Time:06-05

#include
#include
#include
# define price/0.2/$0.2 per car per minute, define with the latter instead of the former and the location of the price with 0.2 instead of
# define Max 2//garage capacity
Int the key ()
{
Int mima=111111;//password
Int yh, the cw=3, CG=0;//yh: user input number the cw//answer the number of CG//input the correct number
Do {
Printf ("... Please enter the 6 digit code... \n");
The scanf (" % d ", & amp; Yh);
If (yh!=mima)
{
The cw -;
Printf (" the rest of the input number is % d times \ n ", the cw);
}
The else
{
Cg++;
Printf (" * * * * password input the correct! * * * * * \ n ");
break;
}
}
While (cw> 0);//password input loop
If (CG==1)
{
Printf (" * * * * * * * * * * * * * * * * * * * * * * * * * * * successfully enter the system * * * * * * * * * * * * * * * * * * * * * * * * * * \ n ");
}
The else
{
Printf (" * * * * * * * * * * * * * * * * * * * * * * * * * * * into the failure of * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \ n ");
Printf (" * * * * * * * * * * * * * * * * * * * * * your password number has been used up! * * * * * * * * * * * * * * * * * * * * * * ");
The exit (1);//abnormal exit
}
}

Struct Car//structure
{
Int carN0;
Int floor;
Int position;
int time;
} car [20];//


Void liulan ()
{
Int b, c;//a: now the number of cars, b: the layer number of the garage, parking Spaces c:
The FILE * fp.
Int e [2] [6]={101102,0,0,0,0,0,0,0,0,0,0};//second six garage
Printf (" all existing parking vehicles information below \ n ");
Printf (" license plate number layers, parking Spaces, parking time \ n ");
For (b=0; B<2; + a + b)
{
For (c=0; C<6; + + c)
{
If (e [b] [c]!=0)
Printf (" % d % d % d % d \ n ", car [b * 6 + c] carN0, car [b * 6 + c] floor, car [b * 6 + c] position, the car [b * 6 + c] time);/[b * 6 + c] said what floor which,
The else
continue;
}
}//rotate through parking cars
If ((fp=fopen (" D: \ \ work \ \ garage information. Dat ", "w"))=NULL)//in write mode to open the file, if change the file does not exist, namely, to establish a new file
{
Fprintf (stderr, "always creat the output file. \ n");
The exit (1);//abnormal exit, exit (0) normal exit
}
printf("\n");
Reading car information}/* */


Void tingche ()
{
Int a, b, c;//a: now the number of cars, b: the layer number of the garage, parking Spaces c:
The FILE * fp.
Int e [2] [6]={101102,0,0,0,0,0,0,0,0,0,0};//array said two layers of garage
Printf (" please enter the license plate number: \ n ");
The scanf (" % d ", & amp; The car [a]. CarN0);
For (b=0; B<2; + a + b)
{
For (c=0; C<6; + + c)
{
If (e [b] [c]==0)
{
E [b] [c]=car [a]. CarN0;
break;
}
}
If (e [b] [c]==car [a]. CarN0);//determine parking
break;
}
The car [a]. Time +=5;//parking time is 5
The car [a]. Floor=b + 1;
The car [a]. Position=c + 1;
If ((fp=fopen (" D: \ \ work \ \ garage information. Dat ", "w"))=NULL)//in write mode to open the file, if change the file does not exist, namely, to establish a new file
{
Fprintf (stderr, "always creat the output file. \ n");//can't open the file
The exit (1);//abnormal exit, exit (0) normal exit
}
For (b=0; B<2; + a + b)
Fprintf (fp, "car [% d] carN0=% d \ n car [% d] floor=% d \ n car [% d] position=% d \ n car [% d] time=% d \ n", a, car [a]. CarN0, a, car [a]. The floor, a, car [a] position, a, car [a]. Time);
The fclose (fp);//put the information in file
Printf (" * * * * * * * * * * * * * * * * * * * * * * * * * * * * stop complete * * * * * * * * * * * * * * * * * * * * * * * * * * ");
printf("\n");
+ + a;
}

Void quche ()
{
Int a, b, c;//a: now the number of cars, b: the layer number of the garage, parking Spaces c:
Int carnum;
Float fee;
The FILE * fp.
Int e [2] [6]={101102,0,0,0,0,0,0,0,0,0,0};
{
{
Printf (" please enter to leave the car license plate number: ");
}
The scanf (" % d ", & amp; Carnum);
For (b=0; B<2; + a + b)
{
If (carnum==car [b] carN0)
{
Fee=car [b] time/5. * 0.2;
Printf (" license plate number for parking for % d: % f \ n ", carnum, fee);
Printf (" * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \ n ");
E b/6 [6] b %=0;
If ((fp=fopen (" D: \ \ work \ \ garage information. Dat ", "w"))=NULL)//in write mode to open the file, if change the file does not exist, namely, to establish a new file
{
Fprintf (stderr, "always creat the output file. \ n");
The exit (1);//abnormal exit, exit (0) normal exit
}
For (c=0; CFprintf (fp, "car [% d] carN0=% d \ n car [% d] floor=% d \ n car [% d] position=% d \ n car [% d] time=% d \ n", c, car [c]. CarN0, c, car [c]. Floor, c, car [c]. The position, c, car [c]. Time);
Fprintf (fp, "car [% d] carN0=% d \ n car [% d] floor=% d \ n car [% d] position=% d \ n car [% d] time=% d \ n", c, car [c]. CarN0, c, car [c]. Floor, c, car [c]. The position, c, car [c]. Time);
The fclose (fp);//information query
break;
}
}
If (b==a)
Printf ("... Take bus success... \n");
The else
Printf (" * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * check without this car * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \ n ");
}

}
Void tuichu ()
{
Printf (" * * * * * * * * * * * * * * * * * * * * * * * * * to exit the system! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \ n ");
Printf (" * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \ n ");
}

Int main ()
{
The key ();
Int a, b, c;//a: now the number of cars, b: the layer number of the garage, parking Spaces c:
Int carnum;
Float fee;
The FILE * fp.
Int e [2] [6]={101102,0,0,0,0,0,0,0,0,0,0};
The car [0]. CarN0=101;
The car [0]. Floor=1;
The car [0]. Position=1;
The car [0]. Time=40;
The car [1]. CarN0=102;
The car [1]. The floor=1;
The car [1]. The position=2;
The car [1]. Time=20;//the existing parking vehicle information
If ((fp=fopen (" D: \ \ work \ \ garage information. Dat ", "w"))=NULL)//in write mode to open the file, if change the file does not exist, namely, to establish a new file
{
Fprintf (stderr, "always creat the output file. \ n");
The exit (1);//abnormal exit, exit (0) normal exit
}
For (a=0; A. & lt; 2; + + a)
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related