怒打1300行代码,一个文件实现停车场管理系统,C++语言代码挑战

停车场管理系统,全网唯一C++单文件,功能全部实现。
摘要由CSDN通过智能技术生成

停车场具有实时功能。话不多说直接上代码,虽然有1300行左右,但是放在DevC++上直接就能跑。C++如果你已经学到位,即使1300行你也可以理解上去。

#include<stdlib.h>
#include<iomanip>   //控制输出格式
#include<iostream>
#include<fstream>  //文件读写
using namespace std;
#define    ERROR    0
#define    OK       1
#define    MAX_STOP 100        //停车场最大容纳量 
#define    MAX_PAVE 20         //最大等候车辆数 = PAVE - 1;存储方式采用队列,队列满时会空出一个单元 
#define    LEngth   10         //定义停车场长度
#define    Width    10 
#include<windows.h>
#define  MaxInt   32767      //表示极大值
#define  MVNum    100        //表示最大顶点数
#include<String.h>
#include<time.h>
typedef char  VerTexType;
typedef double   ArcType;
typedef struct{
	VerTexType vexs[MVNum];
	ArcType    arcs[MVNum][MVNum];
	int vexnum,arcnum;
}ALGraph; 
//定义车辆信息 
typedef struct{
	int year;
	int month;
	int day;
}DATA;

typedef struct{
	int hour;
	int minute;
	int second;
}TIME;

typedef  struct{
	char Lincense[20];         //定义车牌号
	char Parking[4];          //定义车所停车位
	DATA  TimeIn_data;          //进入停车场的日期 
	TIME  TimeIn_time;          //进入停车场的时间 
	DATA  TimeOut_data;         //出停车场的日期
	TIME  TimeOut_time;         //出停车长的时间
	int  Pay;                  //停车费
	int  State;                //车辆状态  0-等待 1-已入场 -1-离开 
}Car;

typedef int status;
//定义停车记录信息 
typedef  struct Stopping{
	Car data;          //用二维数组车位状态 
	Stopping *next;                //记录停车场停了多少辆车 
}Stopping,* LinList;  //LinList用于定于头指针  
//定义候车区停车信息 
typedef  struct{
	char Pave[100][10];
	int count;                 //记录等候车辆数
	int front,rear;          
}Buffer; 
void DateTime(SYSTEMTIME &st);
status InitQueue(Buffer &Q);
status EnQueue(Buffer &Q,char e[]);
status DeQueue(Buffer &Q,char e[]);
status QueueEmpty(Buffer Q);
status QueueFull(Buffer Q);
status InitList(LinList &st);
void CreatList_head(LinList &st,Buffer Q,ALGraph &G,int len[],SYSTEMTIME &Time,int &Stay_enter_panduan,char e[],int stop_day_total[],char Status[100][10]);   //车辆入库 
void ShowList(LinList &st);
status SearchList(LinList &L,char e[]);
int Read(LinList &st,char Status[100][10],Buffer &Q,ALGraph &G,int len[]);
int Write(LinList st,char Status[10][10],Buffer &Q,char dis[12][2],ALGraph &G,double dist[]);
int  day(int year,int month);
status Search_car_State(LinList &st,char e[],Buffer Q);
status Search_car_to_pay(LinList &st,char e[],Buffer Q,SYSTEMTIME &Time,int &money_per_hour,int pay_day_total[],char Status[100][10]);
int LocateVex(ALGraph &G,VerTexType u);
void ShortestPath_DIJ(ALGraph G,int v0,	int Path[]);
status CreateUDM(ALGraph &G,char dis[12][2],double dist[12]);
void Lincense_panduan(char e[]);
int  day_month(int year,int month);
void pay_sum_month(int pay_day_total[367],int pay_month[13],int year,int month);
void Sort_pay_month(int pay_month[13],int num[13]) ;
int main()
{
	Stopping *st; 
	InitList(st);
	char Status[100][10];       //定义停车状态数组 
	for(int i=0;i<100;i++)
	{
		strcpy(Status[i],"0");            //初始化 
	}
	char  dis[12][2] = {'A','B',	      //距离顶点 
						'A','C',	
						'C','D',	
						'D','E',	
						'B','E',	
						'C','G',	
						'D','I',	
						'H','A',	
						'H','J',	
						'A','F',	
						'F','G',	
						'B','I'};
	double dist[12] ={  0.5,        //权值 
						1.8,
						0.7,
						1.2,
						0.2,
						1.1,
						0.9,
						2.5,
						2.2,
						1.4,
						0.6,
						0.4}; 
	Buffer Q;                   	  //队列入队变量 
	ALGraph G;                        //图变量 
	InitQueue(Q);                     //队列初始化 
	int jishu = 0;                    //记录文件中车辆个数 
	int choice;                       //功能选项 
	SYSTEMTIME Time;                  //计算时间变量 
	char e[10];                       //输入车牌号的变量 
	int car_pay = 0;                      //停车费用 
	int len[10] = {0};                //记录停车场停车数量 
	int money_per_hour = 2;           //初始化停车场每小时费用2元 
	int Stay_enter_panduan=0;         //用于等候队列进入停车场情况 
	int choice_search;                //查询选项选择 
	int choice_stopping_search;
	int STATE;                        //停车状态 
	char domin;                       //区域英文 
	int area_concrete;                //具体位置英文 
	int i,j,k;
	int stop_day_total[367] = {0},pay_day_total[367] = {0},leave_day_total[367] = {0};     //0位置不存储元素
	//进行排序调试的值15,18,2,6,8,9,4,6,3,10,58,35,100   106行 
	int pay_month[13] = {0};          //存储12个月份每个月的停车费   0不存东西      
	int year_day;                     //一年的第多少天 
	int panduan;
	int num[13]={0,1,2,3,4,5,6,7,8,9,10,11,12};                      //存储月份 
	int v1,v2;
	int Path[MVNum];
	char now_area;                                                  //当前区域
	char car_area;                                                  //爱车所在区域 
	double distance = 0;                                            //距离 
	int cun[MVNum];                                               
	while(1)
	{	
		cout<<"                                  欢迎使用 “易停”地下停车场管理系统 "<<endl;
		DateTime(Time);
		printf("当前时间是:%d-%02d-%02d %02d:%02d:%02d\n",Time.wYear,Time.wMonth,Time.wDay,Time.wHour, Time.wMinute,Time.wSecond); 
		cout<<"                                            1.上班"<<endl ;
		cout<<"                                            2.车辆入库"<<endl ;
		cout<<"                                            3.车辆驶离"<<endl ;
		cout<<"                                            4.查询"<<endl ;
		cout<<"                                            5.统计"<<endl ;
		cout<<"                                            6.帮我找车"<<endl ;
		cout<<"                                            7.基础数据维护"<<endl ;
		cout<<"                                            8.下班"<<endl ;
		cout<<"输入选项:";
		cin>>choice;
		switch(choice) 
		{
			case 1:
				//上班 
				Read(st,Status,Q,G,len); 
				cout<<"上班了!"<<endl;
				break;
			case 2:
				//车辆入库 
				CreatList_head(st,Q,G,len,Time,Stay_enter_panduan,e,stop_day_total,Status);     //该函数里包括了停车场是否已经满了的判断和进入等候队列的操作 
				break;
			case 3:
				//车辆驶离
				cout<<"输入驶离车辆的车牌号(两位字母+五位数字):";
				cin>>e;
				//判断车牌号是否合法
				Lincen
  • 3
    点赞
  • 29
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值