您好,欢迎访问三七文档
当前位置:首页 > 行业资料 > 交通运输 > C语言交通处罚单管理系统
#includestdio.h#includewindows.h#includestdlib.h#includestring.h#includeconio.hintN;//staticN;structtranficpunishbill{charcp[10];/***车牌号***/charjz[20];/***驾照号***/charkdjj[10];/***开单交警号码***/charcfd[20];/***处罚单号码***/charcfsj[12];/***处罚时间(yyyymmddhhmm,年月日时分)***/}TPB[50];/***TPB[50]中每个元素对应一个处罚单***//*******************************************重定义模块******************************************/voidchongxindy(){printf(请输入N的大小:);scanf(%d,&N);}/*********************************************************************************************//*******************************************输入模块******************************************/voidsave(){FILE*fp;inti;if((fp=fopen(fadan.txt,w))==NULL)//打开文件{printf(不能打开);return;}for(i=0;iN;i++)/***写入文件***/fprintf(fp,\n%5s%10s%13s%11s%12s,TPB[i].cp,TPB[i].jz,TPB[i].kdjj,TPB[i].cfd,TPB[i].cfsj);fclose(fp);//关闭文件}voidshuru(){intj;printf(请输入总数量:);scanf(%d,&N);printf(请输入数据:\n);printf(\n车牌号驾照号开单交警号处罚单号处罚时间\n);for(j=0;jN;j++)scanf(%5s%10s%13s%11s%12s,TPB[j].cp,TPB[j].jz,TPB[j].kdjj,TPB[j].cfd,TPB[j].cfsj);save();return0;}/*********************************************************************************************//*******************************************删除模块******************************************/voidshanchu(){FILE*fp;inti,k,j=-1;charm[10],d[10],f[10];if((fp=fopen(fadan.txt,r))==NULL)//打开文件{printf(不能打开);exit(0);}for(i=0;iN;i++)//读取文件到结构体中fscanf(fp,%s%s%s%s%s,TPB[i].cp,TPB[i].jz,TPB[i].kdjj,TPB[i].cfd,TPB[i].cfsj);fclose(fp);//关闭文件system(cls);printf(删除模块:);printf(\n\n\n);printf(********************************************\n);printf(**\n);printf(**\n);printf(**\n);printf(*1.车牌号2.驾照号3.开单交警号*\n);printf(**\n);printf(**\n);printf(**\n);printf(********************************************\n);printf(\n\n请输入删除选项:);scanf(%d,&k);if(k==1){printf(请输入车牌号:);scanf(%s,m);for(i=0;iN;i++)if(strcmp(m,TPB[i].cp)==0)j=i;}elseif(k==2){printf(请输入驾照号:);scanf(%s,d);for(i=0;iN;i++)if(strcmp(d,TPB[i].jz)==0)j=i;}elseif(k==3){printf(请输入开单交警号:);scanf(%s,f);for(i=0;iN;i++)if(strcmp(f,TPB[i].kdjj)==0)j=i;}if(j!=-1)//在结构体中运算{for(i=j;iN&&j!=-1;i++)TPB[i]=TPB[i+1];N=N-1;}elseif(j==-1)printf(不能打开);if((fp=fopen(fadan.txt,w))==NULL)/***打开文件***/{printf(不能打开);exit(0);}for(i=0;iN;i++)/***写入文件***/fprintf(fp,\n%5s%10s%13s%11s%12s,TPB[i].cp,TPB[i].jz,TPB[i].kdjj,TPB[i].cfd,TPB[i].cfsj);fclose(fp);/***关闭文件***/}/**********************************************************************************************//*******************************************浏览模块******************************************/voidliulan(){FILE*fp;inti,j;if((fp=fopen(fadan.txt,r+))==NULL)//打开文件{printf(不能打开);exit(0);}system(cls);//换屏printf(车牌号驾照号开单交警号处罚单号处罚时间\n);for(i=0,j=0;iN;i++,j++)//读取文件,并输出文件{fscanf(fp,%s%s%s%s%s,TPB[i].cp,TPB[i].jz,TPB[i].kdjj,TPB[i].cfd,TPB[i].cfsj);printf(%5s%10s%13s%11s%12s,TPB[i].cp,TPB[i].jz,TPB[i].kdjj,TPB[i].cfd,TPB[i].cfsj);puts(\n);//空行}fclose(fp);//关闭文件}/********************************************************************************************//********************************************查询模块****************************************/voidchaxun(){inti,k,t=0;charm[10],d[10],f[10];FILE*fp;if((fp=fopen(fadan.txt,r+))==NULL)//打开文件{printf(不能打开);exit(0);}for(i=0;iN;i++)//读取文件{fscanf(fp,%s%s%s%s%s,TPB[i].cp,TPB[i].jz,TPB[i].kdjj,TPB[i].cfd,TPB[i].cfsj);}fclose(fp);//关闭文件system(cls);printf(查询模块);printf(\n\n\n);printf(********************************************\n);printf(**\n);printf(**\n);printf(**\n);printf(*1.车牌号2.驾照号3.开单交警号*\n);printf(**\n);printf(**\n);printf(**\n);printf(********************************************\n);printf(\n\n请输入查询选项:);scanf(%d,&k);//system(cls);if(k==1){printf(请输入车牌号:);scanf(%s,&m);system(cls);for(i=0;iN;i++){if(strcmp(m,TPB[i].cp)==0){printf(车牌号驾照号开单交警号处罚单号处罚时间\n);printf(%5s%10s%13s%11s%12s\n,TPB[i].cp,TPB[i].jz,TPB[i].kdjj,TPB[i].cfd,TPB[i].cfsj);t++;}elseif(strcmp(d,TPB[i].jz)!=0)printf(\n);}}elseif(k==2){printf(请输入驾照号:);scanf(%s,&d);system(cls);for(i=0;iN;i++){if(strcmp(d,TPB[i].jz)==0){printf(车牌号驾照号开单交警号处罚单号处罚时间\n);printf(%5s%10s%13s%11s%12s\n,TPB[i].cp,TPB[i].jz,TPB[i].kdjj,TPB[i].cfd,TPB[i].cfsj);t++;}elseif(strcmp(d,TPB[i].jz)!=0)printf(\n);}}elseif(k==3){printf(请输入开单交警号:);scanf(%s,&f);system(cls);for(i=0;iN;i++){if(strcmp(f,TPB[i].kdjj)==0){printf(车牌号驾照号开单交警号处罚单号处罚时间\n);printf(%5s%10s%13s%11s%12s\n,TPB[i].cp,TPB[i].jz,TPB[i].kdjj,TPB[i].cfd,TPB[i].cfsj);t++;}elseif(strcmp(f,TPB[i].kdjj)!=0)printf(\n);}}}/*********************************************************************************************//********************************************统计模块****************************************/voidtongji(){inti,k,t=0;charm[10],d[10],f[10];FILE*fp;if((fp=fopen(fadan.txt,r+))==NULL)//打开文件{printf(不能打开);exit(0);}for(i=0;iN;i++)//读取文件{fscanf(fp,%s%s%s%s%s,TPB[i].cp,TPB[i].jz,TPB[i].kdjj,TPB[i].cfd,TPB[i].cfsj);}fclose(fp);//关闭文件system(cls);printf(统计模块);printf(\n\n\n);printf(********************************************\n);printf(**\n);printf(**\n);printf(**\n);printf(*1.车牌号2.驾照号3.开单交警号*\n);printf(**\
本文标题:C语言交通处罚单管理系统
链接地址:https://www.777doc.com/doc-6000300 .html