停车管理系统

//
//  main.c
//  泊车管理系统
//
//  Created by 丁小未 on 13-7-14.
//  Copyright (c) 2013年 dingxiaowei. All rights reserved.
//
//题目:泊车管理系统
//(1)管理人员根据口令进入系统
//(2)管理车位信息(车位编号,状态)和每分钟的收费率;
//(3)停车时录入汽车停泊信息(车牌号,车型,停泊位置,停泊开始时间);如果车位已满要给出提示;
//(4)取车时,根据车牌取,如果没有给出提示;需要根据车辆停泊时间自动计算费用并显示在屏幕上。
#include <stdio.h>
#include <string.h>
#include <time.h>
#define MAX 20
struct StopedCar
{
    char carNum[20]; //车牌号
    char carshap[20];//车型
    int areaNum; //停泊位置号码
    char stopedTime[30]; //开始停泊时间
    int h;  //记录小时
    int m;  //记录分钟
};
int total;  //总记录数
char password[20]; //密码
struct StopedCar stopedcar[MAX];
int price=1.0;//默认泊车单价为1¥1M
/***************函数申明******************************************/
void Init();//初始化,文件不存在,则建立,同时记录下文件中记录的个数
int get_menu_choice(); //接受菜单选择
void menu();//菜单相应
void Show_menu();//显示菜单
FILE *file_operate(char *mode); //文件操作类型
void set_psw();//设置密码
int psw_check();//密码验证
int Inputonecar(int i);//根据车位号增加一条记录
void Inputfile(int i,FILE *fp);//将下标为i的记录写入文件
void Input(FILE *fp);//向管理系统中增加记录
int SetPrice();//设置停车单价(例如:¥1for1s)
void GetCarByAreaNum(FILE *fp);//根据车位号取车
/*****以下函数是为了简化部分工作从上面的函数中划分出来的功能**************/
void PrintTitle();//打印头信息
void ShowAllCarInfo(); //显示所有停车信息
void Showonecarinfo(int i);  //显示停车信息
float countMoney(float danjia);//计算根据传入的单价来计算泊车的费用
void Readfile(int i,FILE *fp);//从文件中读取一条记录
int CheckNumber(int areaNum_temp);//检查车位号是否为空,存在返回序号,如果该车位有停车则返回-1
char* GetTime();//获取当前时间
int Cost(char *time1,int danjia);//根据单价和时间差来计算停车消费的价格
int Cost2(int h,int m,int danjia);
void GetCarByAreaNum2(FILE *fp);
int timeh();
int timem();
/***************函数的实现****************************************/
//获取当前系统时间
char* GetTime()
{
    {
        time_t now;
        struct tm *timenow;
        time(&now);
        timenow = localtime(&now);
    char *p = asctime(timenow);
    return p;
    }
}
//返回当前小时
int timeh()
{
    int h;
    time_t   now;
    struct   tm     *timenow;
    time(&now);
    timenow   =   localtime(&now);
    char *p = asctime(timenow);
    h=timenow->tm_hour;
    return h;
}
//返回当前分钟
int timem()
{
    int m;
    time_t   now;
    struct   tm     *timenow;
    time(&now);
    timenow   =   localtime(&now);
    char *p = asctime(timenow);
    m=timenow->tm_min;
    return m;
}
//接受菜单选择
int get_menu_choice()
{
    int menu_ch;
    do {
        printf("输入菜单选项:");
        scanf("%d",&menu_ch);
        if((menu_ch<0)||(menu_ch>9))
            printf("输入错误!");
    } while ((menu_ch<0)||(menu_ch>9));
    return menu_ch;
}
//显示菜单
void Show_menu()
{
    printf(">>>>>>>>>>>>>>>欢迎使用泊车管理系统<<<<<<<<<<<<<<<<\n");
    printf("************************************************\n");
    printf("*   1.新增停车信息         |   2.显示所有停车信息   *\n");
    printf("*   3.按照车牌号取车       |   4.按照车位号取车     *\n");
    printf("*   5.按照车牌号查询车信息  |   6.按照车位号查询车信息*\n");
    printf("*   7.设置泊车单价         |   8.密码设置         *\n");
    printf("*   9.主动清屏            |   0.退出             *\n");
    printf("************************************************\n");
}
//清屏,有点问题
//void clear()
//{
//    system("pause");
//    system("cls");
//}
//菜单响应
void menu()
{
    while (1) {
        Show_menu();
        switch (get_menu_choice()) {
            case 1://新增停车信息
                Input(file_operate("ab"));  //二进制追加写入
                break;
            case 2://显示所有泊车信息
                ShowAllCarInfo();
                break;
            case 3://按照车牌好取车
                break;
            case 4://按照车位号取车
                GetCarByAreaNum2(file_operate("wb"));
                break;
            case 5://按照车牌号查询车位信息
                break;
            case 6: //按照车位号查询车位信息
                break;
            case 7://设置停车价格(例如:¥1for1s)
                SetPrice();
                break;
             case 8://密码设置
                set_psw();
                break;
            case 9://手动清屏
                //clear();
                printf("手动清屏有误!");
                break;
            case 0://结束程序
                //system("cls");
                printf("*********************\n");
                printf("     欢迎使用本系统     \n");
                printf("**********************\n");
                break;
                //exit(0);
            default:
                break;
        }
    }
}
//打印头信息
void PrintTitle()
{
    printf("-------------------------------------------------------------\n");
    printf("   车牌号          车型   停泊车位号          停泊开始时间   \n");
    printf("-------------------------------------------------------------\n");
}
//初始化,文件不存在,则建立,同时记录下文件中的记录数
void Init()
{
    int ii;
    FILE *fp;
    total=0;
    if((fp=fopen("stopedcar.txt","rb"))==NULL)
    {
        fp=fopen("stopedcar.txt","ab");
        //clear();
        menu();
    }
    else
    {
        for(ii=0;feof(fp)==0;ii++)   //feof检查文件是否结束
        {
            Readfile(ii,fp);
        }
        total=ii-1;
    }
    //total=ii-1;
    fclose(fp);
}
//文件操作类型
FILE *file_operate(char *mode)
{
    char choice;
    FILE *fp;
    do
    {
        fflush(stdin);//清空输入缓存,以便不影响后面的输入
        if((fp=fopen("stopedcar.txt",mode))==NULL)
        {
            puts("Fail to open the file!");
            puts("Try again!(Y/N)?");
            scanf("%c",&choice);
        }
        else
            fp=fopen("stopedcar.txt",mode);
    }
    while(choice=='y'||choice=='Y');
    if(choice=='n'||choice=='N'){}
        //exit(1); //异常退出  exit(0);系统正常退出
    return(fp);
}
//从文件中读取一条记录
void Readfile(int i,FILE *fp)
{
    fscanf(fp,"%20s",&stopedcar[i].carNum);
    fscanf(fp,"%20s",&stopedcar[i].carshap);
    fscanf(fp,"%5d",&stopedcar[i].areaNum);
    fscanf(fp,"%30s",&stopedcar[i].stopedTime);
}
//显示打印一条泊车信息
void Showonecarinfo(int i)
{
    printf("%10s   %10s   %1d  %30s \n",stopedcar[i].carNum,stopedcar[i].carshap,stopedcar[i].areaNum,stopedcar[i].stopedTime);
}
//显示打印所有的泊车信息
void ShowAllCarInfo()/*显示打印所有的信息 */
{
    int i;
    printf("有%d个记录:\n",total);
    PrintTitle();
    for(i=0;i<total;i++)
        Showonecarinfo(i);
}
//检查车位号是否为空,存在返回序号,如果该车位没有停车则返回-1
int CheckNumber(int areaNum_temp)
{
    int i,result=0;
    for(i=0;i<total;i++)
    {
        if(stopedcar[i].areaNum==areaNum_temp)
        {
            result=1;
            break;
        }
    }
    if(result==1)
        return i;
    else
        return -1;
}
//根据车位号增加一条记录
int Inputonecar(int i)
{
    int areaNum;
    do
    {
        printf("输入车位号:(如1)");
        scanf("%d",&areaNum);
        if(areaNum<0)
            printf("error!\n");
        if (areaNum>MAX) {
            printf("没有大于%d的车位\n",MAX);
        }
    }
    while(areaNum<0);
    //该车位有停车
    if(CheckNumber(areaNum)>0)
    {
        printf("该车位已经停了车!\n");
        return 0;
    }
    //如果该车位没有停车
    else
    {
        stopedcar[i].areaNum=areaNum;  //将停车的车位号记录为当前的车位号
        printf("Input 车牌号(less than 20 chars):");
        scanf("%s",stopedcar[i].carNum);
        printf("车型号(例如:baomaX6):");
        scanf("%s",&stopedcar[i].carshap);
        char *time=GetTime();//获取当前系统时间
        stopedcar[i].h=timeh();//记录小时
        stopedcar[i].m=timem();//记录分钟
        char *q=stopedcar[i].stopedTime;
        strcpy(q, time);//将当前时间赋值给car.StopedTime
        PrintTitle();
        Showonecarinfo(i);
        //Inputfile(i,fp);
        return 1;
    }
}
//把下标为i 的记录写入文件
void Inputfile(int i,FILE *fp)
{
    fscanf(fp,"%20s",&stopedcar[i].carNum);
    fscanf(fp,"%20s",&stopedcar[i].carshap);
    fscanf(fp,"%5d",&stopedcar[i].areaNum);
    fscanf(fp,"%30s",&stopedcar[i].stopedTime);
}
//向管理系统中增加记录
void Input(FILE *fp)
{
    int i;
    i=total;
    if(Inputonecar(i))
    {
        total++;
        Inputfile(i,fp);
    }
    fclose(fp);
}
//设置泊车单价
int SetPrice()
{
    printf("请设置泊车单价:(例如:1¥for 1 m)\n");
    scanf("%d",&price);
    printf("您设置的单价是:%d¥1M\n",price);
    return price;
}
int Cost2(int h,int m,int danjia)
{
    int money;
    //获取当前小时和分钟
    int hnow=timeh();
    int mnow=timem();
    return money=((hnow-h)*60+(mnow-m))*danjia;
}
//根据单价和时间差来计算停车消费的价格
int Cost(char *time1,int danjia)
{
    int money;
    char forein[2];
    char now[2];
    int minu;
    int sec;
    int t1,t2;
    for (int i=14; i<=15; i++,time1++) {
        forein[i-14]=time1[i];
    }
    minu=(forein[0]-48)*10+(forein[1]-48);
    for (int i=17; i<=18; i++,time1++) {
        forein[i-17]=time1[i];
    }
    sec=(forein[0]-48)*10+(forein[1]-48);
    t1=minu*60+sec;
    char *p=GetTime();
    for (int i=14; i<=15; i++,time1++) {
        forein[i-14]=p[i];
    }
    minu=(forein[0]-48)*10+(forein[1]-48);
    for (int i=17; i<=18; i++,time1++) {
        forein[i-17]=p[i];
    }
    sec=(forein[0]-48)*10+(forein[1]-48);
    t2=minu*60+sec;
    money=(t2-t1)*danjia;
    return money;
}
//根据车位号取车
void GetCarByAreaNum2(FILE *fp)
{
    int i,j,k,no_temp,choice2;
    printf("输入要取车的车位号:(例如1)");
    scanf("%d",&no_temp);
    i=CheckNumber(no_temp);
    if(i>=0)
    {
        PrintTitle();
        Showonecarinfo(i);//根据车位号来查询是第几个
        printf("确认取车?(1.是/2.否)");
        scanf("%d",&choice2);
        if(choice2==1)
        {
//            char *time1=stopedcar[i].stopedTime;
//            printf(time1);
            int h=stopedcar[i].h;
            int m=stopedcar[i].m;
            printf("您需要支付¥%d的停车费\n",Cost2(h,m,price));
            for (j=i; j<total; j++) {
                strcpy(stopedcar[j].carNum, stopedcar[j+1].carNum);
                strcpy(stopedcar[j].carshap, stopedcar[j+1].carshap);
            }
            total--;
            for (k=0; k<total; k++) {
                Inputfile(k, fp);
            }
        }
    }
    else
        printf("该车位上没有停车\n");
}
//根据车位号取车
void GetCarByAreaNum(FILE *fp)
{
    int i,j,k,no_temp,choice2;
    printf("输入要取车的车位号:(例如1)");
    scanf("%d",&no_temp);
    i=CheckNumber(no_temp);
    if(i>=0)
    {
        PrintTitle();
        Showonecarinfo(i);//根据车位号来查询是第几个
        printf("确认取车?(1.是/2.否)");
        scanf("%d",&choice2);
        if(choice2==1)
        {
            char *time1=stopedcar[i].stopedTime;
            printf(time1);
            printf("您需要支付¥%d的停车费\n",Cost(time1,price));
            for (j=i; j<total; j++) {
                strcpy(stopedcar[j].carNum, stopedcar[j+1].carNum);
                strcpy(stopedcar[j].carshap, stopedcar[j+1].carshap);
            }
            total--;
            for (k=0; k<total; k++) {
                Inputfile(k, fp);
            }
        }
    }
    else
        printf("该车位上没有停车\n");
}
//设置密码
void set_psw()
{
    char psw_set[20],psw_check[20],c;
    unsigned int i;
    FILE *fp;
    do
    {   printf("You must set password first!\n");
        printf("Enter password:(less than 12 numbers and key'.'for end)\n");
        for(i=0;(c=getchar())!='.';i++)
        {
            //putchar('*');
            psw_set[i]=c;
        }
        psw_set[i]='\0';
        printf("-----------------\n");
        printf("conform password:");
        for(i=0;(c=getchar())!='.';i++)
        {
            //putchar('*');
            psw_check[i]=c;
        }
        psw_check[i]='\0';
        //printf("------------\n");
        if(strcmp(psw_set,psw_check)==0)
        {printf("Set password success!\n");
            strcpy(password,psw_set);
        }
        else
            printf("error!\n");
    }
    while(strcmp(psw_set,psw_check)!=0);
    //clear();
    fp=fopen("password.txt","wb");
    fprintf(fp,"%s",password);
    fclose(fp);
}
//密码验证
int psw_check()
{
    unsigned int i=1,j=1;
    FILE *fp;
    char pword[20],c;
    if((fp=fopen("password.txt","rb"))==NULL)
    {
        fp=fopen("password.txt","a");
        set_psw();
    }
    fscanf(fp,"%s",password);
    fclose(fp);
    do
    {
        printf("\nInput password:key'.'for end(%d/three times)",j);
        for(j=0;(c=getchar())!='.';j++)
        {
            //putchar('*');
            pword[j]=c;
        }
        pword[j]='\0';
        i++;
    }
    while(strcmp(pword,password)!=0&&i<=3);
    if(i<=3)
        return 1;
    else
    {
        printf("You have tryed for three times,fail to open the file!\n");
        return 0;
    }
}
int main(int argc, const char * argv[])
{
    if(psw_check())
    {
        Init();
        //clear();
        menu();
    }
    return 0;
}


      掌握基于腾讯人工智能(AI)的车牌识别技术,使用车牌识别技术实现一个完整的停车管理系统,项目包括网页调用摄像头拍照,车牌拍照识别,上传车牌图片识别,用户管理,车辆管理(临时车与包月车),车辆出场,入场管理,停车费收费管理,按照临时车或包月车自动计算停车费,系统参数设置,修改用户密码及安全退出等功能,该系统采用Jsp技术,使用SSM框架,Mysql数据库,ajax技术及人工智能等相关技术实现。重要通知:本课程根据腾讯AI车牌识别新接口,更新了新接口源代码,发布程序,购买了课程的同学可以下载新程序,包括(运行程序及源代码),更新时间:2021-2-17项目开发技术:java,jsp,mysql,MyBatis,SpringMVC,jquery,ajax,json项目运行环境:jdk1.7及以上版本,tomcat6.0及以上版本,mysql5.5及以上版本项目开发工具: 本项目开发工具是Eclipse,也支持myEclipse,Intellij Idea等其他版本开发工具相关课程学习顺序本校课程是培养JAVA软件工程师及JSP WEB网络应用程序开发,android工程师的全套课程,课程学习顺序如下:JAVA初级工程师:    1、计算机基础    2、HTML语言基础    3、C语言从入门到精通+贪吃蛇游戏    4、贪吃蛇游戏    5、SQL SERVER数据库基础    6、JAVA从入门到精通+推箱子游戏+QQ即时通讯软件    7、推箱子游戏;    8、仿QQ即时通讯软件;JAVA中级工程师:    9、SQLSERVER数据库高级    10、SQLSERVER从入门到精通(基础+高级)              11、JavaScript从入门到精通,    12、JSP从入门到精通+点餐系统,    13、JSP从入门到精通+在线视频学习教育平台,    14、JSP从入门到精通+大型电商平台;    15、XML从入门到精通,    16、数据结构(JAVA版),JAVA高级工程师:    17、Oracle数据库从入门到精通,    18、ajax+jquery从入门到精通,    19、EasyUI从入门到精通,SSH框架:    20、Struts2从入门到精通课程,    21、Hibernate从入门到精通课程,    22、Spring从入门到精通课程;    23、Echarts从入门到精通,    24、Excel基于POI的导入导出工作流框架:    25、Activiti流程框架从入门到精通    26、JBPM流程框架从入门到精通SSM框架:    27、MyBatis从入门到精通    28、Spring MVC从入门到精通面试题:    29、职业生涯规划及面试题集锦商业项目:    30、微信公众号在线支付系统    31、微信生活缴费在线支付系统    32、支付宝生活缴费在线支付系统    33、在线考试系统    34、手机订餐管理系统,    35、CRM客户关系管理系统    36、大型房地产CRM销售管理系统    37、CMPP2,CMPP3移动网关系统人工智能:    38、人脸识别在线考试系统    39、人脸识别系统项目实战    40、车牌识别系统项目实战    41、身份证识别系统项目实战    42、营业执照识别系统项目实战          43、名片识别管理系统
1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 、4下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。、可私 6信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 、4下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。、可 6私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 、4下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。、可私 6信博主看论文后选择购买源代码。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值