优化的停车场.docx
《优化的停车场.docx》由会员分享,可在线阅读,更多相关《优化的停车场.docx(79页珍藏版)》请在冰豆网上搜索。
优化的停车场
#include"stdio.h"
#include"iostream"
#include"windows.h"
#include"stdlib.h"
#include"string.h"
#include
#include
#include
#include"windows.h"
#include
#include
#include"time.h"
#include"stdlib.h"
#defineSIZE5
#defineBUFSIZE2500
#definePUTSSIZE50
#defineOK1
#defineNULL0
#defineERROR0
#defineTURE1
#defineFALSE0
#defineOVERFLOW-2
typedefintStatus;
#defineMAXQSIZE100
#defineMAX3/*车库容量*/
#defineprice1.5/*每车每分钟费用*/
usingnamespacestd;
voidWelcome()
{
system("color3f");
printf("********************************************************************************");
printf("**********************************\n");
printf("***************************\n");
printf("********************************\n");
printf("*******************\n");
printf("**********************************\n");
printf("*********************************************************************************");
}
voidshowtime()
{
inta,b,c,d,e,f;
tmmytime;//用来储存时间的结构体
_getsystime(&mytime);//获取系统时间
a=mytime.tm_year+1900;//这里注意,获取的年的0年为1900年,所以需要用年加上1900才为实际年份
b=mytime.tm_mon+1;//月份为0-11,所以需要+1
c=mytime.tm_mday;
d=mytime.tm_hour;
e=mytime.tm_min;
f=mytime.tm_sec;
printf("********现在时间为:
%d年%d月%d日%d:
%d:
%d",a,b,c,d,e,f);//输出年月日时分秒
}
voidmainmeau()
{
printf("*******************************************************************************");
cout<<"******1.信息管理系统******"<cout<<"** 2.应用系统 **"<cout<<"*****3.退出 ******"</*cout<<"****";*/showtime();
cout<<"****";
printf("********");
printf("********************************************************************************");
}
classVIP
{//定义VIP类
stringname;
stringchepaihao;
intphonenum;
stringmima;
doubleshengyuqian;
public:
VIP();
VIP*next;
stringgetName();
stringgetChepaihao();
intgetPhonenum();
stringgetMima();
doublegetShengyuqian();
};
VIP:
:
VIP()
{
name="zhangsan";
chepaihao="A0000";
phonenum=00000000000;
mima="000000";
}
stringVIP:
:
getName()//姓名
{
returnname;
}
stringVIP:
:
getChepaihao()//车牌号
{
returnchepaihao;
}
intVIP:
:
getPhonenum()//联系方式
{
returnphonenum;
}
stringVIP:
:
getMima()//密码
{
returnmima;
}
doubleVIP:
:
getShengyuqian()//余额
{
returnshengyuqian;
}
intqueren_lutao()//确认函数
{
charpanduan;
panduan=getch();
if(panduan=='y')
return1;
if(panduan=='n')
return0;
else
{
cout<<"无法识别输入字符,请重新输入(y/n)"<queren_lutao();
}
}
//姓名的输出
voidOutputName(charm[])
{
intj=0;
intcount=0;
charch;
charname[21]={'\0'};
FILE*fp;
fp=fopen(m,"r");
cout<<"姓名:
";
fseek(fp,0,SEEK_SET);
while((ch=fgetc(fp))!
=EOF)
{
if(ch==91)
while(ch!
=93)
{
ch=fgetc(fp);
if(ch!
=93)
{
name[count]=ch;
count++;
}
}
elseif(ch==93)
break;
}
for(inti=0;i{
if(name[i]!
='')
cout<else
break;
}
cout<fclose(fp);
}
//车牌号的输出
voidOutputChepaihao(charm[])
{
intcount=0;
charch;
charchepaihao[6]={'\0'};
FILE*fp;
fp=fopen(m,"r");
cout<<"此时的车牌号:
";
fseek(fp,0,SEEK_SET);
while((ch=fgetc(fp))!
=EOF)
{
if(ch==123)
while(ch!
=125)
{
ch=fgetc(fp);
if(ch!
=125)
{
chepaihao[count]=ch;
count++;
}
}
elseif(ch==125)
break;
}
for(inti=0;icout<cout<fclose(fp);
}
intVIP_denglu(charn)
{
intt=1,i=0;
chara[6];
charch;
charMIMA[6]={'\0'};
charmima[6]={'\0'};
a[0]=n;
a[1]='\0';
strcat(a,".txt");
FILE*fp;
if((fp=fopen(a,"r+"))==NULL)
{
cout<<"该注册号不存在,请查证!
"<system("PAUSE");
return0;
}
while((ch=fgetc(fp))!
=EOF)
{
if(ch==35)
{
fseek(fp,0,SEEK_CUR);
for(inti=0;i<6;i++)
{
ch=fgetc(fp);
mima[i]=ch;
}
mima[i]='\0';
}
else
{
i=0;
continue;
}
}
cout<<"请输入密码:
"<while(1==t)
{
while((ch=_getch())!
=13&&i<6)
{
if(ch==42)
{
printf("\b\b");
i--;
}
else
{
_putch('*');
MIMA[i++]=ch;
}
}
MIMA[i]='\0';
if(i!
=6)
{
if(0==i)
{
cout<<"密码不能为空!
"<cout<<"按任意键重新输入,结束输入请按'*'号键..."<ch=getch();
if(42!
=ch)
{
t=1;
i=0;
system("cls");
cout<<"请输入密码:
"<}
}
else
{
cout<<"密码为六位!
"<cout<<"按任意键重新输入,结束输入请按'*'号键..."<ch=getch();
if(42!
=ch)
{
t=1;
i=0;
system("cls");
cout<<"请输入密码:
"<}
}
}
else
{
if(strcmp(mima,MIMA)==0)
{
t=0;
system("cls");
cout<登录中..."<getchar();
fclose(fp);
//system("PAUSE");
getchar();
return1;
}
else
{
system("cls");
cout<<"密码错误!
"<cout<<"按任意键重新输入,结束输入请按'*'号键..."<ch=getch();
if(42!
=ch)
{
i=0;
system("cls");
cout<<"请输入密码:
"<}
else
{
fclose(fp);
return0;
}
}
}
}
}
//联系方式的输出
voidOutputPhonenum(charm[])
{
intcount=0;
charch;
charphonenum[12]={'\0'};
FILE*fp;
fp=fopen(m,"r");
cout<<"联系方式:
";
fseek(fp,0,SEEK_SET);
while((ch=fgetc(fp))!
=EOF)
{
if(ch==60)
while(ch!
=62)
{
ch=fgetc(fp);
if(ch!
=62)
{
phonenum[count]=ch;
count++;
}
}
elseif(ch==62)
break;
}
for(inti=0;icout<cout<fclose(fp);
}
//修改车牌号
intxiugaiChepaihao(charm[])
{intcount=0;
intt=0,i=0;
FILE*fp;
charch;
charbuf[BUFSIZE]={'\0'};//'\0'初始化数组
fp=fopen(m,"r");
if(NULL==fp)
{
printf("文件打开失败!
");
exit(0);
}
ch=fgetc(fp);
while(ch!
=EOF)//统计字节个数
{ch=fgetc(fp);
count++;
}
while(fread(buf,sizeof(char),count,fp))//将文件中内容全部存入buf
{}
fclose(fp);
fp=fopen(m,"r+");
fputs(buf,fp);
fread(buf,sizeof(char),count,fp);
fseek(fp,0,SEEK_SET);
cout<<"请输入新车牌号:
"<while(t==0)
{
while((ch=fgetc(fp))!
=EOF)//依次扫描修改
{
if(ch==123)
{
while(ch!
=125)
{fseek(fp,0,SEEK_CUR);
ch=getchar();
//查错处理
try
{
if(i==0)
{
if(ch>90||ch<65)
{
++i;
throwch;
}
}
else
{
if(ch>57||ch<48)
{
++i;
throwch;
}
}
++i;
}catch(char)
{
cout<<"第"<
++t;
}catch(...)
{
cout<<"出现未知错误!
"<++t;
}
fputc(ch,fp);
fseek(fp,0,SEEK_CUR);
ch=fgetc(fp);
fseek(fp,-1,SEEK_CUR);
}
}
elseif(ch==125)
break;
}
getchar();
fseek(fp,0,SEEK_SET);
if(t!
=0)
{
t=0;
cout<<"请重新输入"<i=0;
}
elseif(t==0)
{
cout<<"输入正确!
"<t=1;
i=0;
}
}
//确认修改部分
{cout<<"是否确认修改(y/n)?
"<intt=queren_lutao();
getchar();
if(t==0)
{
cout<<"修改取消"<fseek(fp,0,SEEK_SET);
fputs(buf,fp);//重新写入信息
}
else
{
system("cls");
cout<<"修改成功!
"<cout<}
}
fclose(fp);
cout<<"";OutputChepaihao(m);
return0;
}
intxiugaiPhonenum(charm[])//修改联系方式
{intcount=0;
FILE*fp;
charch;
intt=0,i=0;
charbuf[BUFSIZE]={'\0'};//'\0'初始化数组
fp=fopen(m,"r");
if(NULL==fp)
{
printf("文件打开失败!
");
exit(0);
}
ch=fgetc(fp);
while(ch!
=EOF)//统计字节个数
{ch=fgetc(fp);
count++;
}
while(fread(buf,sizeof(char),count,fp))//将文件中内容全部存入buf
{}
fclose(fp);
fp=fopen(m,"r+");
fputs(buf,fp);
fread(buf,sizeof(char),count,fp);//将文件中的内容写入buf,供后来恢复信息使用
fseek(fp,0,SEEK_SET);
cout<<"请输入新的手机号码(十一位):
"<while(t==0)
{
while((ch=fgetc(fp))!
=EOF)//依次扫描修改
{
if(ch==60)
{
while(ch!
=62)
{fseek(fp,0,SEEK_CUR);
ch=getchar();
//查错处理
try
{
if(ch>57||ch<48)
{
++i;
throwch;
}
++i;
}catch(char)
{
cout<<"第"<
++t;
}catch(...)
{
cout<<"出现未知错误!
"<++t;
}
fputc(ch,fp);
fseek(fp,0,SEEK_CUR);
ch=fgetc(fp);
fseek(fp,-1,SEEK_CUR);
}
}
elseif(ch==62)
break;
}
getchar();
fseek(fp,0,SEEK_SET);
if(t!
=0)
{
cout<<"输入错误!
请重新输入"<t=0;
i=0;
}
else
{
t=1;
cout<<"输入正确!
"<i=0;
}
}
//确认修改部分
{cout<<"是否确认修改(y/n)?
"<intt=queren_lutao();
getchar();
if(t==0)
{
cout<<"修改取消"<fseek(fp,0,SEEK_SET);
fputs(buf,fp);//重新写入信息
}
else
{
system("cls");
cout<<"修改成功!
"<cout<}
}
fclose(fp);
cout<<"";OutputPhonenum(m);
return0;
}
voidxiugaiMima(charm[])//修改密码
{
intcount=0;
FILE*fp;
charch;
charbuf[BUFSIZE]={'\0'};//'\0'初始化数组
fp=fopen(m,"r");
if(NULL==fp)
{
printf("文件打开失败!
");
return;
}
ch=fgetc(fp);
while(ch!
=EOF)//统计字节个数
{
ch=fgetc(fp);
count++;
}
while(fread(buf,sizeof(char),count,fp))//将文件中内容全部存入buf
{}
fclose(fp);
fp=fopen(m,"r+");
fputs(buf,fp);
fread(buf,sizeof(char),count,fp);//将文件中的内容写入buf,供后来恢复信息使用
fseek(fp,0,SEEK_SET);
cout<<"请输入新的密码(六位):
"<while((ch=fgetc(fp))!
=EOF)//依次扫描修改
{
if(ch==35)
{
while(ch!
=42)
{
fseek(fp,0,SEEK_CUR);
ch=getchar();
fputc(ch,fp);
fseek(fp,0,SEEK_CUR);
ch=fgetc(fp);
fseek(fp,-1,SEEK_CUR);
}
}
elseif(ch==42)
break;
}
getchar();
fseek(fp,0,SEEK_SET);
//确认修改部分
{
cout<<"是否确认修改(y/n)?
"<intt=queren_lutao();
getchar();
if(t==0)
{
cout<<"修改取消"<fseek(fp,0,SEEK_SET);
fputs(buf,fp);//重新写入信息
}
else
{
system("cls");
cout<<"修改成功!
"<cout<}
}
fclose(fp);
}
voidVIP_x