




已阅读5页,还剩21页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
C 语 言 课 程 实 习 报 告建筑工地信息管理系统一. 题目要求建筑工地信息管理系统要求要建立与建筑相关的四个文件信息:1)项目2)工地3)配件 4)商家;建立文件以后,根据项目、工地或商家完成各项工作的追加、删除、修改和更新查询操作。二. 需求分析 要求整个系统设计为建筑工地的信息输入、追加、删除、修改、浏览、查询模块。三. 总体设计如示意图:开始菜单输入追加删除修改退出浏览项目工地配件商家查找 插入四. 详细设计1.主函数main()menu();2.菜单menu()int n,w1;doputs(ntt*MENU*n);puts(tt 建筑工地信息系统 nn);puts(tttt1.Enter data);puts(tttt2.Addition data);puts(tttt3.Delete data);puts(tttt4.Modify data);puts(tttt5.Insert data);puts(tttt6.Browse all);puts(tttt7.Browse project); puts(tttt8.Browse site);puts(tttt9.Browse outfit);puts(tttt10.Browse sale);puts(tttt11.Search date);puts(tttt12.Exit);puts(nntt*n);printf(Choice your number(1-12): bbb);scanf(%d,&n);if(n12)w1=1;getchar();else w1=0;while(w1=1);switch(n)case 1:enter();break;case 2:add();break;case 3:del();break;case 4:modify();break;case 5:insert();break;case 6:browse();break;case 7:browse_project();break;case 8:browse_site();break;case 9:browse_outfit();break;case 10:browse_sale();break;case 11:search();break;case 12:exit(0);3各功能模块设计(1)输入模块/整个系统数据结构:struct project char site_num10;char site_name20;char site_city20;char outfit_num10;char outfit_name20;char outfit_color10;char outfit_place20;char sale_num10;char sale_name20;char sale_state10;char sale_city20;int outfit_n;proN;注意:proN中的N为项目数量,本程序宏定义#define N 50/流程示意图:i!=0保存save(n)输入用户要输入职工记录的个数ni从0到n-1调用输入函数input(i)/程序实现 enter()int i,n;printf(How many information(0-%d)?:,N-1);scanf(%d,&n);printf(nEnter data nownn);for(i=0;in;i+) printf(nInput %dth student record.n,i+1); input(i);if(i!=0) save(n); save_project(n); save_site(n); save_outfit(n); save_sale(n);printf_back();(2)追加模块流程图调用n=load();并计算可以启示录的个数n输入用户要追加工程的个数nk=m+ni从n到k调用输入函数input(i)保存追加的记录/追加模块程序add()int i,n,m,k;FILE *fp;n=load();printf(How many record are you want to add(0-%d)?:,N-1-n);scanf(%d,&m);k=m+n;for(i=n;ik;i+) printf(n Addtion %dth project record.n,i-n+1); input(i); for(i=n;ik;i+)if(fp=fopen(main.txt,ab)=NULL) printf(Cannot open filen);if(fwrite(&proi,sizeof(struct project),1,fp)!=1) printf(file write errorn);fclose(fp);if(fp=fopen(project.txt,ab)=NULL) printf(nCannot open filen); return NULL; fprintf(fp,%s,%s,%s,%d,proi.sale_num,proi.outfit_num,proi.site_num,proi.outfit_n); fclose(fp);if(fp=fopen(site.txt,ab)=NULL) printf(nCannot open filen); return NULL; fprintf(fp,%s,%s,%s,proi.site_num,proi.site_name,proi.site_city);fclose(fp);if(fp=fopen(outfit.txt,ab)=NULL) printf(nCannot open filen); return NULL; fprintf(fp,%s,%s,%s,%s,%d,proi.outfit_num,proi.outfit_name,proi.outfit_color,proi.outfit_pla,proi.outfit_n);fclose(fp);if(fp=fopen(sale.txt,ab)=NULL) printf(nCannot open filen); return NULL; fprintf(fp,%s,%s,%s,%s,proi.sale_num,proi.sale_name,proi.sale_state,proi.sale_city);fclose(fp);printf_back();(3)删除模块/删除模块程序del()struct project p;FILE *fp;int i,n,w1,w2,j;n=load();doprintf_face();for(i=0;in;i+)printf_one(i); do printf(nnWhich needed delete?What do you want enter?nt1).site_num 2)outfit_num 3)sale_num 4)outfit_n 5)NO and backn); printf(Please choose:(1-5): bbb); scanf(%d,&w2); switch(w2) case 1:printf(site_num:);scanf(%s,&p.site_num);break; cas 2:printf(outfit_num:);scanf(%s,&p.outfit_num);break; case 3:printf(sale_num:);scanf(%s,&p.sale_num);break; case 4:printf(outfit_n:);scanf(%s,&p.outfit_n);break; case 5:menu(); for(i=0;in;i+) for(j=i;jn;j+)if(strcmp(p.site_num,proi.site_num)|strcmp(p.outfit_num,proi.outfit_num)|strcmp(p.sale_num,proi.sale_num)|(p.outfit_n=proi.outfit_n)=0); proi=proj; printf(%dth record has been deleted!n,i-1); n-; save(n); printf_face(); printf_one(i-1); while(jn);printf(Are you delete another?nt1)Yes 2)No and Back,i);printf(tnPlease choose:(1-2): bb);scanf(%d,&w1);while(w1=1); printf_back();(4)修改模块 /流程图示意图是否找到记录修改不成功是否继续返回主菜单输入要修改的号码:开始选择1)工地好2)配件好 3)商号是否修改成功显示结果显示所有记录,让用户看哪个要修改/修改模块程序modify()struct project p;FILE *fp;int i,n,k,w0=1,w1,w2=0;n=load();dok=-1;printf_face();for(i=0;in;i+)if(i!=0)&(i%10=0)printf(nnRemember NO.which needed modify.pass any key to continue.);getch();puts(nn);printf_one(i);doprintf(nnEnter Sale_num that you want to modify! sale_num:);scanf(%s,p.sale_num);for(i=0;in;i+)if(strcmp(p.sale_num,proi.sale_num)=0)k=i;p=proi;if(k=-1) printf(nnNO exist!please again);while(k=-1);printf_face();printf_one(k);w1=modify_data(k,n);if(w1=1)printf(nSuccessful -.nnAre you modify another?nt1)Yes 2)Back with savet);printf(nPlease choose:(1-2): bb);scanf(%d,&w0);w2=1;elsew0=0;if(w2=1)prok=p;if(w0!=1&w2=1)save(n);while(w0=1);menu();(5)插入模块/插入模块insert()int i,j,n,c,t;struct project p;n=load();puts(nInput one data.n);doinput(n);printf_face();printf_one(n);printf(nnAre you sure?nnt1).Sure t2).cancel and againt3).Back without saven);printf(Please choose:(1-3): bbb);scanf(%d,&c);if(c=1)for(i=0;in;i+)for(j=i;jn+1;j+)if(proj.outfit_nproj+1.outfit_n)p=proj;proj=proj+1;proj+1=p;save(n+1);printf_back();else if(c!=2) menu();while(c=2);(6)浏览模块/浏览模块示意图i!=0显示数据n=load();打开所有项目文件i从0到n-1调用输出函数printf_one(i)/所有项目显示模块browse()int i,j,n;n=load();printf_face();for(i=0;in;i+)if(i!=0&i%10=0)printf(nnPass any key to continue.);getch();puts(nn);printf_one(i);printf(tnThere are %d record.n,n);printf(nPass any key to back.);getch();menu();/销售商-配件-建筑工地 浏览模块browse_project()int i,j,n;n=load();printf_project1();for(i=0;in;i+) if(i!=0&i%10=0) printf(nnPass any key to continue.); getch(); puts(nn); printf_project(i);printf(tnThere are %d record.n,n);printf(nPass any key to back.);getch();menu();/建筑工地 浏览模块browse_site()int i,j,n;n=load();printf_site1();for(i=0;in;i+) if(i!=0&i%10=0) printf(nnPass any key to continue.); getch(); puts(nn); printf_site(i);printf(tnThere are %d record.n,n);printf(nPass any key to back.);getch();menu();/配件 浏览模块browse_outfit()int i,j,n;n=load();printf_outfit1();for(i=0;in;i+) if(i!=0&i%10=0) printf(nnPass any key to continue.); getch(); puts(nn); printf_outfit(i);printf(tnThere are %d record.n,n);printf(nPass any key to back.);getch();menu();/销售商 浏览模块browse_sale()int i,j,n;n=load();printf_sale1();for(i=0;in;i+) if(i!=0&i%10=0) printf(nnPass any key to continue.); getch(); puts(nn); printf_sale(i);printf(tnThere are %d record.n,n);printf(nPass any key to back.);getch();menu();(7)查找模块/查找示意图项目号配件号等号家号显示找到的记录是否继续查找选择查找或返回主菜单返回主菜单在菜单中选择查找功能选择要查找的数据项目查找比较No exist!/查找模块search()int i,j,n,k,w1=1,w2,w3,w4,w5;struct project p;n=load();do do k=-1; printf_face(); for(i=0;in;i+) printf_one(i);printf(nnWhat num do you want enter?nt1)sale_city 2).site_city 3)NO and backn);printf(Please choose:(1-3): bbb);scanf(%d,&w5);switch(w5)case 1:printf(sale_city:);scanf(%s,p.sale_city);break;case 2:printf(site_city:);scanf(%s,p.site_city);break;case 3:menu();for(i=0;in;i+)if(strcmp(p.site_city,proi.site_city)&strcmp(p.sale_city,proi.sale_city)=0)k=i;printf_one(k);if(k=-1)printf(nnNO exist!);printf(nnAre you again?nt1).again 2)NO and backn);printf(Please choose:(1-2): bb);scanf(%d,&w1);if(w1=2)break;while(k=-1&w1=1);w4=0;w3=0;if(k!=-1)printf(nnWhat do you want to do? nt1).Search another 2).Modify 3).Delete 4).Back menun);printf(Please choose:(1-4): bbb);scanf(%d,&w2);switch(w2) case 2:w3=modify_data(k,n);break; case 3:printf(nAre you sure?nt1).Sure 2).No and back);scanf(%d,&w4); if(w3=1|w4=1)save(n);printf(nnSuccessful. -.);printf(nnWhat do you want to do?nt1).Search another 2).Backn);printf(Please choose:);scanf(%d,&w2);while(w2=1);menu();4.公共函数/保存整个系统数据save(int n)FILE *fp;int i;if(fp=fopen(main.txt,wb)=NULL)printf(nCannot open filen);return NULL; for(i=0;in;i+)if(fwrite(&proi,sizeof(struct project),1,fp)!=1)printf(file write errorn);fclose(fp);/保存 主项目save_project(int n)FILE *fp;int i;if(fp=fopen(project.txt,wb)=NULL)printf(nCannot open filen);return NULL; for(i=0;in;i+) fprintf(fp,%s,%s,%s,%d,proi.sale_num,proi.outfit_num,proi.site_num,proi.outfit_n);fclose(fp);/保存建筑工地信息save_site(int n)FILE *fp;int i;if(fp=fopen(site.txt,wb)=NULL) printf(nCannot open filen); return NULL; for(i=0;in;i+)fprintf(fp,%s,%s,%s,proi.site_num,proi.site_name,proi.site_city);fclose(fp);/保存配件信息save_outfit(int n)FILE *fp;int i;if(fp=fopen(outfit.txt,wb)=NULL)printf(nCannot open filen); return NULL; for(i=0;in;i+) fprintf(fp,%s,%s,%s,%s,%d,proi.outfit_num,proi.outfit_name,proi.outfit_color,proi.outfit_place,proi.outfit_n);fclose(fp);/保存销售商信息save_sale(int n)FILE *fp;int i;if(fp=fopen(sale.txt,wb)=NULL) printf(nCannot open filen); return NULL; for(i=0;in;i+)fprintf(fp,%s,%s,%s,%s,proi.sale_num,proi.sale_name,proi.sale_state,proi.sale_city);fclose(fp);/加载文件int load()FILE *fp;int i;if(fp=fopen(main.txt,rb)=NULL) printf(nCannot open filen); return NULL;for(i=0;!feof(fp);i+) fread(&proi,sizeof(struct project),1,fp);fclose(fp);return(i-1);/文件输入-完成字符串类型输入char_input(int i)int j=1,k,w1,n=12;dow1=0;for(j=1;j12;j+)switch(j)case 1:printf(site_num.:);scanf(%s,&proi.site_num);break;case 2:printf(site_name.:);scanf(%s,&proi.site_name);break;case 3:printf(site_city.:);scanf(%s,&proi.site_city);break;case 4:printf(outfit_num.:);scanf(%s,&proi.outfit_num);break;case 5:printf(outfit_name.:);scanf(%s,&proi.outfit_name);break;case 6:printf(outfit_color.:);scanf(%s,&proi.outfit_color);break;case 7:printf(outfit_place.:);scanf(%s,&proi.outfit_place);break;case 8:printf(sale_num.:);scanf(%s,&proi.sale_num);break;case 9:printf(sale_name.:);scanf(%s,&proi.sale_name);break;case 10:printf(sale_state.:);scanf(%s,&proi.sale_state);break;case 11:printf(sale_city.:);scanf(%s,&proi.sale_city);break;if(!pro)puts(Input error!Only be made up of (0-9).Please reinput!n);w1=1;break;if(w1!=1)for(k=0;knn 1).site_num 2).site_name 3).site_city 4).outfit_num 5).output_namen 6).output_color 7).output_place 8).sale_num 9).sale_name 10).sale_staten11).sale_city 12).outfit_n 13).cancle and back);printf(Please choose:(1-13): bbb);scanf(%d,&c);if(c13|c13|c1);doswitch(c) case 1:printf(site_num.:);scanf(%s,&proi.site_num);break;case 2:printf(site_name.:);scanf(%s,&proi.site_name);break;case 3:printf(site_city.:);scanf(%s,&proi.site_city);break;case 4:printf(outfit_num.:);scanf(%s,&proi.outfit_num);break;case 5:printf(outfit_name.:);scanf(%s,&proi.outfit_name);break;case 6:printf(outfit_color.:);scanf(%s,&proi.outfit_color);break;case 7:printf(outfit_place.:);scanf(%s,&proi.outfit_place);break;case 8:printf(sale_num.:);scanf(%s,&proi.sale_num);break;case 9:printf(sale_name.:);scanf(%s,&proi.sale_name);break;case 10:printf(sale_state.:);scanf(%s,&proi.sale_state);break;case 11:printf(sale_city.:);scanf(%s,&proi.sale_city);break;case 12:printf(outfit_n.:);scanf(%d,&proi.outfit_n);break;case 13:menu();puts(nNow:n);printf_face();printf_one(i);printf(nAre you sure?nt1).Sure 2).No and remodify 3).Back without saven);printf(Please choose:(1-3): bb);scanf(%d,&w1);while(w1=2);return(w1);/显示主文件结构printf_face()puts(nt*建筑工地项目信息*);puts(nt*);printf(t site_num site_name site_city);printf(ntnoutfit_num outfit_name outfit_color outfit_palce); printf(nt sale_num sale_name sale_state sale_city outfit_n);puts(nt*);/显示项目文件结构printf_project1()printf(t-项目信息-n );printf(n t销售商号码*配件号*工地号*配件数目n );puts( -);/显示建筑工地文件结构printf_site1()printf(t-工地信息-n);printf(nt工地号*名称*所在地方n);puts( -);/显示配件文件结构printf_outfit1()printf(nt -配件信息-n);printf(nt 配件号码*名称*颜色*产地*数量n);puts( -);/显示销售商文件结构printf_sale1()printf(nt-商家信息-n);printf(nt生产商号*名称*状态*城市n);puts( -);/显示主文件数据printf_one(int i)printf(t%6s%13s%14s,proi.site_num,proi.site_name,proi.site_city);printf(nt%6s%13s%14s%14s,proi.outfit_num,proi.outfit_name,proi.outfit_color,proi.outfit_place);printf(nt%6s%13s%14s%14s%10d,proi.
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 废旧锂电池综合回收利用项目施工方案
- 咨询型会员推广方案
- 智能化楼宇控制系统方案
- 四月保险营销方案
- 全国薪酬方案咨询热线
- 健身房营销费用分析方案
- 信息系统建设应急预案模板
- 钢构车间疫情防控应急预案
- 跨境童装电商本土化营销策略与效果评估报告2025
- 工装模具检验维修记录
- 毒品成瘾原因课件
- 2025年公需课《人工智能赋能制造业高质量发展》试题及答案
- 2025-2026学年外研版七年级英语上册(全册)教学设计(附目录)
- 2025-2026学年人美版(2024)小学美术三年级上册教学计划及进度表
- 连锁药店考勤管理制度
- 2025年国航机务系统AMECO工程师岗位校园招聘笔试参考题库附带答案详解
- YS/T 261-2011锂辉石精矿
- 食堂办 安全风险分级管控子清单
- 国学《弟子规》 课件
- 新款h2夜视移动电源
- 企业内部控制风险清单
评论
0/150
提交评论