C语言课程设计-身份证管理系统

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

课程设计说明书安徽师范大学物理与电子信息学院CollegeofPhysicsandElectronicInformation,AnhuiNormalUniversity1《身份证管理系统》课程设计报告题目身份证管理系统学号姓名年级专业09级电子信息工程(2)班指导教师完成日期2010年6月28日课程设计说明书安徽师范大学物理与电子信息学院CollegeofPhysicsandElectronicInformation,AnhuiNormalUniversity2一、课程设计的目的进一步掌握和利用C语言进行程设计的能力,理解和运用结构化程设计的思想和方法,熟练掌握条件语句、循环、数组、结构体、函数操作,初步掌握开发一个小型实用系统的基本方法,学会高度一个较长程序的基本方法和利用流程图或N-S图表示算法,将本课程所学的知识合理地运用于实践当中。了解一些书上没有的函数及使用方法。二、设计方案论证1.设计思路利用数组对人们的信息进行循环的输入,记录以及输出等操作。它主要包括以下功能:输入,显示,删除,按姓名和出生年月日查找,按年龄阶段的不同进行统计以及读入和写入文档等。2.分工我和朱琼雪(0908267)为一组做的课程设计,并且在写源程序和进行上机调试的时候一直都是一起协同合作,最终完成了整个程序。3.流程图课程设计说明书安徽师范大学物理与电子信息学院CollegeofPhysicsandElectronicInformation,AnhuiNormalUniversity3菜单界面选择1选择2选择3选择4选择5是是是是是添加个人信息删除个人信息统计在某个年龄段的人数查询并输出个人信息开始重新返回菜单界面退出程序按姓名按出生日期课程设计说明书安徽师范大学物理与电子信息学院CollegeofPhysicsandElectronicInformation,AnhuiNormalUniversity44.源程序#includestdio.h#includestdlib.h#includestring.hstructpeople{charname[10],sex,num[20];intyear;shortmonth,day,age;structpeople*peop;};voidpadd(void);voidpdelete(void);voidpcount(void);voidpsearch(void);voidpprintf(structpeople*pp);voidpsave(void);voidpread(void);structpeople*hp=NULL;intinti=0;voidmain(void){intintj=0;charch;课程设计说明书安徽师范大学物理与电子信息学院CollegeofPhysicsandElectronicInformation,AnhuiNormalUniversity5pread();while(intj!=5){printf(\t\tPleaseSelectATask:\n\t\t1.Add\n\t\t2.Delete\n\t\t3.Count\n\t\t4.Search\n\t\t5.Exit\n\t\tPleaseSelectOne:);scanf(%d,&intj);if(intj==1){padd();}elseif(intj==2){pdelete();}elseif(intj==3){pcount();}elseif(intj==4){psearch();}if((fp=fopen(data.dat,rb+))==NULL){exit(1);}else{课程设计说明书安徽师范大学物理与电子信息学院CollegeofPhysicsandElectronicInformation,AnhuiNormalUniversity6while(pp!=NULL){fwrite(pp,sizeof(structpeople),1,fp);pp=pp-peop;}fwrite(pep,sizeof(structpeople),1,fp);fclose(fp);printf(\t\tSucceed!\n\t\t);}free(pep);}elseif(intj==5){printf(AreYouSure?(Y/N));ch=getchar();if(ch=='N'||ch=='n'){intj=0;}}else{printf(\t\tWrongTask);exit(1);}}}voidpadd(void){课程设计说明书安徽师范大学物理与电子信息学院CollegeofPhysicsandElectronicInformation,AnhuiNormalUniversity7structpeople*pp=NULL;pp=hp;hp=(structpeople*)malloc(sizeof(structpeople));hp-peop=pp;printf(\t\tPleaseInputInfomation(NameAgeSexBirthday(YearMonthDay)IDCardNumber):\n);scanf(%s%hd%c%d%hd%hd%s,hp-name,&hp-age,&hp-sex,&hp-year,&hp-month,&hp-day,hp-num);pprintf(hp);psave();system(pause);system(cls);}voidpdelete(void){charname[10],ch;structpeople*pp=hp,*pep=hp;printf(\t\tInputName:);getchar();gets(name);while(pp!=NULL){if(strcmp(pp-name,name)==0){break;}pep=pp;课程设计说明书安徽师范大学物理与电子信息学院CollegeofPhysicsandElectronicInformation,AnhuiNormalUniversity8pp=pp-peop;}printf(\t\tAreYouSure?(Y/N));ch=getchar();if(ch=='Y'||ch=='y'){if(pp==hp){hp=pp-peop;free(pp);}else{pep-peop=pp-peop;free(pp);}psave();}system(pause);system(cls);}voidpcount(void){shortmaxage=0,minage=0,inti=0;structpeople*pp=hp;printf(\t\tInputAge((MinAge)(MaxAge)):);scanf(%hd%hd,&minage,&maxage);课程设计说明书安徽师范大学物理与电子信息学院CollegeofPhysicsandElectronicInformation,AnhuiNormalUniversity9while(pp!=NULL){if(pp-age=minage&&pp-age=maxage){pprintf(pp);inti++;}pp=pp-peop;}printf(Sumis%d\n\t\t,inti);system(pause);system(cls);}voidpsearch(void){intyear=0;shortmonth=0,day=0,inti=0;structpeople*pp=hp;charname[10];if(hp==NULL){printf(\t\tNodata!\n);}else{printf(\t\tPleaseSelectATask:\n\t\t1.ByName\n\t\t2.ByBirthday\n\t\tPleaseSelect:);课程设计说明书安徽师范大学物理与电子信息学院CollegeofPhysicsandElectronicInformation,AnhuiNormalUniversity10scanf(%d,&inti);if(inti==1){printf(\t\tInputName:);getchar();gets(name);while(pp!=NULL){if(strcmp(pp-name,name)==0){pprintf(pp);}pp=pp-peop;}}elseif(inti==2){printf(\t\tInputBirthday:);scanf(%d%hd%hd,&year,&month,&day);while(pp!=NULL){if(year==pp-year&&month==pp-month&&day==pp-day){pprintf(pp);}pp=pp-peop;}}课程设计说明书安徽师范大学物理与电子信息学院CollegeofPhysicsandElectronicInformation,AnhuiNormalUniversity11else{printf(\t\tWrongTask!);exit(1);}}system(pause);system(cls);}voidpprintf(structpeople*pp){printf(\t\t%-10s%-4d%-2c%-6d%-4d%-4d%-20s\n\t\t,pp-name,pp-age,pp-sex,pp-year,pp-month,pp-day,pp-num);}voidpread(void){FILE*fp;intinti=0;structpeople*pp=NULL,*pep,*p;hp=pp=(structpeople*)malloc(sizeof(structpeople));pep=(structpeople*)malloc(sizeof(structpeople));strcpy(pep-name,);strcpy(pep-num,);pep-sex='\0';课程设计说明书安徽师范大学物理与电子信息学院CollegeofPhysicsandElectronicInformation,AnhuiNormalUniversity12pep-age=-1;pep-day=0;pep-month=0;pep-year=0;if((fp=fopen(data.dat,rb))==NULL){printf(\t\tNoFileAvailable!\n);if((fp=fopen(data.dat,wb))==NULL){exit(1);}else{fwrite(pep,sizeof(structpeople),1,fp);hp=NULL;printf(\t\tANewFileHaveBeenRebuilded!\n);}}else{fread(pep,sizeof(structpeople),1,fp);while(pep-age!=-1){*pp=*pep;p=pp;p-peop=pp=(structpeople*)malloc(sizeof(structpeople));inti++;课程设计说明书安徽师范大学物理与电子信息学院CollegeofPhysicsandElectronicInformation,AnhuiNormalUniversity13fread(pep,sizeof(structpeople),1,fp);}if(inti==0){hp=NULL;}else{p-peop=NULL;}}fclose(fp);free(pp);free(pep);}voidpsave(void){structpeople*pep,*pp=hp;FILE*fp;pep=(structpeople*)malloc(sizeof(structpeople));strcpy(pep-name,);strcpy(pep-num

1 / 22
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功