C语言课程设计《高速公路联网收费系统》代码
合集下载
相关主题
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
printf("┏━━━━━━━━━━━━━━━━━━━━━┓\n");
printf("┃ 1.发卡┃\n");
printf("┃ 2.检卡并收费┃\n");
printf("┃ 3.查询┃\n");
printf("┃ 4.注销并退出系统┃\n");
printf("┃ 5.退出系统┃\n");
printf("┗━━━━━━━━━━━━━━━━━━━━━┛\n");
choice=(rand()%k)+1; //随机生成choice,格式rand()%k即要求产生k以内的
for(m=1;m<=9*NUM;m++)
{
if(cars[m].is_in=='n' && cars[m].station_in==0 && cars[m].station_out==startkey && cars[m].flag==choice)
#include <conio.h>
char *mytime(struct tm *timeptr); //获取系统时间的函数
void Delay(int n); //延时函数
char *filename(int startkey);
void initialize(struct car *cars,int num,FILE *fp); ///初始化函数
fclose(fp);
printf("\t欢迎登录广东同三高速公路联网收费系统\n");
printf("┏━━━━━━━━━━━━━━━━━━━━┓\n");
printf("┃ 1.湛江2.茂名3.阳江┃\n");
printf("┃ 4.开平5.佛山6.广州┃\n");
printf("┃ 7.深圳8.汕头9.汾水关┃\n");
printf("┃3.三类车:中型客车、大型普通客车、中型货车、大型豪华客车┃\n");
printf("┃4.四类车:大型货车、大型拖(挂)车、20英尺集装箱车┃\n");
printf("┃5.五类车:重型货车、重型拖(挂)车、40英尺集装箱车┃\n");
printf("┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛\n");
}
fclose(fp);
printf("登记完毕,请发卡放行,并按任意键回到主菜单\a");
getche();
}
else if(key==2)
{
system("cls");
printf("请输入卡号(按0返回):");
while(1)
{
ch='y';
fflush(stdin);
while(scanf("%d%c",&choice,&enter)==0 || enter!='\n')
作者:吴侠志
就读院校:东莞理工学院
#include "stdafx.h"
#define NUM 4
#define max_len 8
#include <string.h>
#include <math.h>
#include <dos.h>
#include <time.h>
#include <stdlib.h>
num=1;
fp=fopen("标记.txt","w+");
fprintf(fp,"%d",num);
fclose(fp);
fp=fopen("记录.txt","w+");
for(i=1;i<=9*NUM;i++)
{
fprintf(fp,"%d %d %c %lf %d %d %s\t%s\t\n",cars[i].card_num,cars[i].car_type,cars[i].is_in,cars[i].money,cars[i].station_in,cars[i].station_out,cars[i].time_in,cars[i].time_out);
printf("请选择车型,并输入序号:");
while(1)
{
fflush(stdin);
while(scanf("%d%c",&size,&enter)==0 || enter!='\n')
{
printf("\terror!!!input again:");
fflush(stdin);
}
if(size==0 || size==1 || size==2 || size==3 || size==4 || size==5)break;
continue;
}
else
{
printf("\terror!!!input again:");
fflush(stdin);
continue;
}
}
if(key==1)
{
system("cls");
timer=time(NULL);
tblock=localtime(&timer);
srand( (unsigned)time(NULL));//用即时的系统时间来做随机数种子.生成随机数
{
j++;
break;
}
}
k=0;
for(m=1;m<=9*NUM;m++)
{
if(cars[m].is_in=='n' && cars[m].station_in==0 && cars[m].station_out==startkey)
{
k++;
cars[m].flag=k;
}
}
if((key==1 && k>0) || (key==2 && j>0) || key==3 || key==4 || key==5ቤተ መጻሕፍቲ ባይዱbreak;
{
break;
}
else
{
printf("\terror!!!input again:");
continue;
}
}
printf("初始化中……");
fp=fopen("标记.txt","a+");
fscanf(fp,"%d",&num);
fclose(fp);
fp=fopen("password.txt","a+");
{
int i,key,choice,j,k,m,size;
double pay,money;
char enter,pwd[max_len+1],password[max_len+1],ch;
FILE *fp;
fp=fopen("标记.txt","a+");
fclose(fp);
fp=fopen("记录.txt","a+");
char *address[10]={"0","湛江","茂名","阳江","开平","佛山","广州","深圳","汕头","汾水"};
char *kind[6]={"特殊车","一类车","二类车","三类车","四类车","五类车"};
struct car
{
int card_num; /*卡号*/
printf("┗━━━━━━━━━━━━━━━━━━━━┛\n");
printf("请选择所在站点,并输入该序号:");
int startkey;
while(1)
{
fflush(stdin);
while(scanf("%d%c",&startkey,&enter)==0 || enter!='\n')
int car_type;
int station_in;
char time_in[26];
int station_out;
char time_out[26];
char is_in;
double money;
int flag;
}cars[9*NUM+1];
int num=0;
int pass=0;
int main(int argc, char* argv[])
int refer(struct car *cars,int startkey); //查询
int km[10]={0,0,82,162,288,368,391,514,800,867}; /*记录各站与首站的里程,单位:km */
double price[6]={0.0,0.6,1.2,1.8,2.4,3.0}; /*记录各类车的里程价位,单位:元/辆公里*/
fscanf(fp,"%d",&pass);
fclose(fp);
if(pass==0)
{
fp=fopen("password.txt","w+");
fprintf(fp,"%d",88888888);
fclose(fp);
}
fp=fopen("记录.txt","a+");
rewind(fp);
initialize(cars,num,fp);
printf("请选择,并输入序号:");
while(1)
{
while(scanf("%d%c",&key,&enter)==0 || enter!='\n')
{
printf("\terror!!!input again:");
fflush(stdin);
}
fp=fopen("标记.txt","r+");
{
printf("\terror!!!input again:");
fflush(stdin);
}
if(startkey==1 || startkey==2 || startkey==3 || startkey==4 || startkey==5 || startkey==6 || startkey==7 || startkey==8 || startkey==9)
{
break;
}
}
printf("卡号是:%d\n现在时间是:%s\n",m,mytime(tblock));
cars[m].station_in=startkey;
cars[m].station_out=0;
strcpy(cars[m].time_in,mytime(tblock));
strcpy(cars[m].time_out,"无");
fclose(fp);
fp=fopen("标记.txt","w+");
fprintf(fp,"%d",num);
fclose(fp);
fp=fopen("记录.txt","w+");
for(i=1;i<=9*NUM;i++)
{
fprintf(fp,"%d %d %c %lf %d %d %s\t%s\t\n",cars[i].card_num,cars[i].car_type,cars[i].is_in,cars[i].money,cars[i].station_in,cars[i].station_out,cars[i].time_in,cars[i].time_out);
fclose(fp);
Delay(5);
time_t timer;
struct tm *tblock,*a;
timer=time(NULL);
a=localtime(&timer);
while(1)
{
system("cls");
fflush(stdin);
printf("所在地:%s站\n登录时间:%s\n",address[startkey],mytime(a));
fscanf(fp,"%d",&num);
fclose(fp);
fp=fopen("记录.txt","r+");
rewind(fp);
initialize(cars,num,fp);
fclose(fp);
j=0;
for(i=1;i<=9*NUM;i++)
{
if(cars[i].is_in=='y' && cars[i].station_in!=startkey && cars[i].station_out==0)
}
fclose(fp);
printf("┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n");
printf("┃0.特殊车:军警车、紧急车┃\n");
printf("┃1.一类车:小轿车、吉普车、的士头人货车、摩托车┃\n");
printf("┃2.二类车:面包车、小型人货车、轻型货车、小型客车┃\n");
else if(key==2 && j==0)
{
printf("\t目前尚无车辆要离站!!!input again:");
fflush(stdin);
continue;
}
else if(key==1 && k==0)
{
printf("\t目前卡片不足!!!input again:");
fflush(stdin);
else
{
printf("\terror!!!input again:");
continue;
}
}
cars[m].is_in='y';
cars[m].car_type=size;
fp=fopen(filename(startkey),"a+");
fprintf(fp,"%30s%8d%12s%20s\n\n",mytime(tblock),m,kind[cars[m].car_type],"发卡,放行");
printf("┃ 1.发卡┃\n");
printf("┃ 2.检卡并收费┃\n");
printf("┃ 3.查询┃\n");
printf("┃ 4.注销并退出系统┃\n");
printf("┃ 5.退出系统┃\n");
printf("┗━━━━━━━━━━━━━━━━━━━━━┛\n");
choice=(rand()%k)+1; //随机生成choice,格式rand()%k即要求产生k以内的
for(m=1;m<=9*NUM;m++)
{
if(cars[m].is_in=='n' && cars[m].station_in==0 && cars[m].station_out==startkey && cars[m].flag==choice)
#include <conio.h>
char *mytime(struct tm *timeptr); //获取系统时间的函数
void Delay(int n); //延时函数
char *filename(int startkey);
void initialize(struct car *cars,int num,FILE *fp); ///初始化函数
fclose(fp);
printf("\t欢迎登录广东同三高速公路联网收费系统\n");
printf("┏━━━━━━━━━━━━━━━━━━━━┓\n");
printf("┃ 1.湛江2.茂名3.阳江┃\n");
printf("┃ 4.开平5.佛山6.广州┃\n");
printf("┃ 7.深圳8.汕头9.汾水关┃\n");
printf("┃3.三类车:中型客车、大型普通客车、中型货车、大型豪华客车┃\n");
printf("┃4.四类车:大型货车、大型拖(挂)车、20英尺集装箱车┃\n");
printf("┃5.五类车:重型货车、重型拖(挂)车、40英尺集装箱车┃\n");
printf("┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛\n");
}
fclose(fp);
printf("登记完毕,请发卡放行,并按任意键回到主菜单\a");
getche();
}
else if(key==2)
{
system("cls");
printf("请输入卡号(按0返回):");
while(1)
{
ch='y';
fflush(stdin);
while(scanf("%d%c",&choice,&enter)==0 || enter!='\n')
作者:吴侠志
就读院校:东莞理工学院
#include "stdafx.h"
#define NUM 4
#define max_len 8
#include <string.h>
#include <math.h>
#include <dos.h>
#include <time.h>
#include <stdlib.h>
num=1;
fp=fopen("标记.txt","w+");
fprintf(fp,"%d",num);
fclose(fp);
fp=fopen("记录.txt","w+");
for(i=1;i<=9*NUM;i++)
{
fprintf(fp,"%d %d %c %lf %d %d %s\t%s\t\n",cars[i].card_num,cars[i].car_type,cars[i].is_in,cars[i].money,cars[i].station_in,cars[i].station_out,cars[i].time_in,cars[i].time_out);
printf("请选择车型,并输入序号:");
while(1)
{
fflush(stdin);
while(scanf("%d%c",&size,&enter)==0 || enter!='\n')
{
printf("\terror!!!input again:");
fflush(stdin);
}
if(size==0 || size==1 || size==2 || size==3 || size==4 || size==5)break;
continue;
}
else
{
printf("\terror!!!input again:");
fflush(stdin);
continue;
}
}
if(key==1)
{
system("cls");
timer=time(NULL);
tblock=localtime(&timer);
srand( (unsigned)time(NULL));//用即时的系统时间来做随机数种子.生成随机数
{
j++;
break;
}
}
k=0;
for(m=1;m<=9*NUM;m++)
{
if(cars[m].is_in=='n' && cars[m].station_in==0 && cars[m].station_out==startkey)
{
k++;
cars[m].flag=k;
}
}
if((key==1 && k>0) || (key==2 && j>0) || key==3 || key==4 || key==5ቤተ መጻሕፍቲ ባይዱbreak;
{
break;
}
else
{
printf("\terror!!!input again:");
continue;
}
}
printf("初始化中……");
fp=fopen("标记.txt","a+");
fscanf(fp,"%d",&num);
fclose(fp);
fp=fopen("password.txt","a+");
{
int i,key,choice,j,k,m,size;
double pay,money;
char enter,pwd[max_len+1],password[max_len+1],ch;
FILE *fp;
fp=fopen("标记.txt","a+");
fclose(fp);
fp=fopen("记录.txt","a+");
char *address[10]={"0","湛江","茂名","阳江","开平","佛山","广州","深圳","汕头","汾水"};
char *kind[6]={"特殊车","一类车","二类车","三类车","四类车","五类车"};
struct car
{
int card_num; /*卡号*/
printf("┗━━━━━━━━━━━━━━━━━━━━┛\n");
printf("请选择所在站点,并输入该序号:");
int startkey;
while(1)
{
fflush(stdin);
while(scanf("%d%c",&startkey,&enter)==0 || enter!='\n')
int car_type;
int station_in;
char time_in[26];
int station_out;
char time_out[26];
char is_in;
double money;
int flag;
}cars[9*NUM+1];
int num=0;
int pass=0;
int main(int argc, char* argv[])
int refer(struct car *cars,int startkey); //查询
int km[10]={0,0,82,162,288,368,391,514,800,867}; /*记录各站与首站的里程,单位:km */
double price[6]={0.0,0.6,1.2,1.8,2.4,3.0}; /*记录各类车的里程价位,单位:元/辆公里*/
fscanf(fp,"%d",&pass);
fclose(fp);
if(pass==0)
{
fp=fopen("password.txt","w+");
fprintf(fp,"%d",88888888);
fclose(fp);
}
fp=fopen("记录.txt","a+");
rewind(fp);
initialize(cars,num,fp);
printf("请选择,并输入序号:");
while(1)
{
while(scanf("%d%c",&key,&enter)==0 || enter!='\n')
{
printf("\terror!!!input again:");
fflush(stdin);
}
fp=fopen("标记.txt","r+");
{
printf("\terror!!!input again:");
fflush(stdin);
}
if(startkey==1 || startkey==2 || startkey==3 || startkey==4 || startkey==5 || startkey==6 || startkey==7 || startkey==8 || startkey==9)
{
break;
}
}
printf("卡号是:%d\n现在时间是:%s\n",m,mytime(tblock));
cars[m].station_in=startkey;
cars[m].station_out=0;
strcpy(cars[m].time_in,mytime(tblock));
strcpy(cars[m].time_out,"无");
fclose(fp);
fp=fopen("标记.txt","w+");
fprintf(fp,"%d",num);
fclose(fp);
fp=fopen("记录.txt","w+");
for(i=1;i<=9*NUM;i++)
{
fprintf(fp,"%d %d %c %lf %d %d %s\t%s\t\n",cars[i].card_num,cars[i].car_type,cars[i].is_in,cars[i].money,cars[i].station_in,cars[i].station_out,cars[i].time_in,cars[i].time_out);
fclose(fp);
Delay(5);
time_t timer;
struct tm *tblock,*a;
timer=time(NULL);
a=localtime(&timer);
while(1)
{
system("cls");
fflush(stdin);
printf("所在地:%s站\n登录时间:%s\n",address[startkey],mytime(a));
fscanf(fp,"%d",&num);
fclose(fp);
fp=fopen("记录.txt","r+");
rewind(fp);
initialize(cars,num,fp);
fclose(fp);
j=0;
for(i=1;i<=9*NUM;i++)
{
if(cars[i].is_in=='y' && cars[i].station_in!=startkey && cars[i].station_out==0)
}
fclose(fp);
printf("┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n");
printf("┃0.特殊车:军警车、紧急车┃\n");
printf("┃1.一类车:小轿车、吉普车、的士头人货车、摩托车┃\n");
printf("┃2.二类车:面包车、小型人货车、轻型货车、小型客车┃\n");
else if(key==2 && j==0)
{
printf("\t目前尚无车辆要离站!!!input again:");
fflush(stdin);
continue;
}
else if(key==1 && k==0)
{
printf("\t目前卡片不足!!!input again:");
fflush(stdin);
else
{
printf("\terror!!!input again:");
continue;
}
}
cars[m].is_in='y';
cars[m].car_type=size;
fp=fopen(filename(startkey),"a+");
fprintf(fp,"%30s%8d%12s%20s\n\n",mytime(tblock),m,kind[cars[m].car_type],"发卡,放行");