1、C语言课程设计设备管理系统一份可以在vc6.0等软件上运行的C语言代码清单,其中一个主函数,设置多个调用函数,分别实现排序,输入,读取等功能模块。#include#include#include#include#define feipeineicun(p) do p=(shebei*)malloc(sizeof(shebei);if(p=NULL)printf(内存分配失败!);exit(-1); while(0)#define len sizeof(shebei)typedef struct time int year; int mouth; int day;time;typedef str
2、uct shebei int bianhao; char mingcheng15; char zhonglei15; int danjia; int niandai; char chanjia15; char baofei10; time time; struct shebei *next;shebei;/extern int /函数声明下面void caidan(shebei *top);int xuanze();shebei *xinxiluru(shebei *top);void neirongxianshi(shebei *top);void xinxichazhao(shebei *
3、top);shebei *xinxixiugai(shebei *top);shebei *xinxishanchu(shebei *top);shebei *shebeibaofei(shebei *top);shebei *xinxipaixu(shebei *top);void fenleitongji(shebei *top);void tongmingguibing(shebei *top);void baocun(shebei *top);/#include头文件.hvoid main() shebei *top; printf(t*n); printf(t-n); printf(
4、t*n); printf(t- -n); printf(t* 欢迎进入单位仪器设备基本信息管理系统 *n); printf(t- -n); printf(t*n); printf(t-n); printf(t*n); do top=(shebei*)malloc(sizeof(shebei);if(top=NULL)printf(内存分配失败!);exit(-1); while(0); top-next=NULL; caidan(top);/#include头文件.hvoid caidan(shebei *top) while(1) switch(xuanze() case 1: top=xi
5、nxiluru(top); break; case 2: neirongxianshi(top); break; case 3: xinxichazhao(top); break; case 4: top=xinxixiugai(top); break; case 5: top=xinxishanchu(top); break; case 6: top=shebeibaofei(top); break; case 7: top=xinxipaixu(top); break; case 8: tongmingguibing(top); /先同名合并 fenleitongji(top); brea
6、k; case 9: baocun(top); break; default: printf(退出操作,拜拜!n); exit(0); int xuanze() int n; printf(n1.增加记录n); printf(2.查看信息n); printf(3.查找信息n); printf(4.修改信息n); printf(5.删除信息n); printf(6.设备报废n); printf(7.信息排序n); printf(8.分类统计n); printf(9.保存信息n); printf(按0退出n); for(;) scanf(%d,&n); if(n9) printf(n输入错误,请重
7、新输入:); else break; return n;/#include头文件.hshebei *shebeibaofei(shebei *top) shebei *p; char b15,c; p=top-next; if(top-next=NULL) printf(没有信息记录,返回菜单选择n); return top; printf(请输入要报废的设备名称:); scanf(%s,b); while(p) if(strcmp(b,p-mingcheng)=0) if(strcmp(p-baofei,是)!=0) printf(将要报废的设备信息如下:n); printf(设备编号 设备
8、名称 设备种类 设备单价 购进年代 生产厂家 是否报废n); printf(%d %s %s %d %d %s %sn, p-bianhao,p-mingcheng,p-zhonglei,p-danjia,p-niandai,p-chanjia,p-baofei); printf(是否确认报废?(Y/N):); scanf(%c,&c); scanf(%c,&c); if(c=y|c=Y) strcpy(p-baofei,是); printf(此设备已被报废n); else printf(此设备已经为报废状态n); break; p=p-next; if(p=NULL) printf(没有找到
9、该设备信息n); printf(按任意键返回主菜单n); getchar(); getchar(); return top;/#include头文件.hshebei *xinxiluru(shebei *top) int n; shebei *p,*q; p=top; while(p-next!=NULL) p=p-next; printf(请输入设备信息:n输入0则结束n); do feipeineicun(q); printf(请输入设备的编号); scanf(%d,&q-bianhao); if(q-bianhao=0) break; printf(请输入设备的名称); scanf(%s
10、,q-mingcheng); printf(请输入设备的种类); scanf(%s,q-zhonglei); printf(请输入设备的单价); scanf(%d,&q-danjia); printf(请输入设备的年代); scanf(%d,&q-niandai); printf(请输入设备的生产产家); scanf(%s,q-chanjia); printf(请输入设备的报废情况n); printf(0.没有报废n1.已经报废n); for(;) scanf(%d,&n); if(n!=0&n!=1) printf(输入错误,请重新输入:n); else break; if(n=0) str
11、cpy(q-baofei,否); q-time.year=q-time.day=q-time.day=0; else strcpy(q-baofei,是); printf(请输入报废时间(格式为2015 10 12):); scanf(%d%d%d,&q-time.year,&q-time.mouth,&q-time.day); p-next=q; p=q; p-next=NULL; while(1); free(q); printf(录入完毕,按任意键返回主菜单n); getchar(); getchar(); return top;/#include头文件.hvoid neirongxia
12、nshi(shebei *top) shebei *p; p=top-next; if(top-next) printf(设备信息如下:n); printf(设备编号 设备名称 设备种类 设备单价 购进年代 生产厂家 是否报废n); else printf(记录为空,返回菜单n); while(p) printf(%d %s %s %d %d %s %sn, p-bianhao,p-mingcheng,p-zhonglei,p-danjia,p-niandai,p-chanjia,p-baofei); p=p-next; printf(按任意键返回主菜单n); getchar(); getch
13、ar();/#include头文件.hvoid baocun(shebei *top) FILE *fp; shebei *p; p=top-next; if(top-next=NULL) printf(没有东西可存!n); return; if(fp=fopen(shebei.txt,wb)=NULL) printf(n); exit(1); while(p) fwrite(p,len,1,fp); p=p-next; fclose(fp); printf(信息已经存入文件,请继续n);/#include头文件.hvoid xinxichazhao(shebei *top) shebei *
14、p; int a,n; char b15; p=top-next; if(top-next=NULL) printf(没有记录信息,返回菜单选择n); return; printf(查找方式:n); printf(1.按编号查找n2.按名称查找n); for(;) scanf(%d,&n); if(n!=2&n!=1) printf(输入错误,请重新输入:n); else break; if(n=1) printf(请输入设备编号:); scanf(%d,&a); while(p) if(a=p-bianhao) printf(查找到的设备信息如下:n); printf(设备编号 设备名称 设
15、备种类 设备单价 购进年代 生产厂家 是否报废n); printf(%d %s %s %d %d %s %sn, p-bianhao,p-mingcheng,p-zhonglei,p-danjia,p-niandai,p-chanjia,p-baofei); break; p=p-next; else if(n=2) printf(请输入设备名称:); scanf(%s,b); while(p) if(strcmp(b,p-mingcheng)=0) printf(查找到的设备信息如下:n); printf(设备编号 设备名称 设备种类 设备单价 购进年代 生产厂家 是否报废); printf
16、(%d %s %s %d %d %s %sn, p-bianhao,p-mingcheng,p-zhonglei,p-danjia,p-niandai,p-chanjia,p-baofei); break; p=p-next; if(p=NULL) printf(没有找到该信息n); printf(按任意键返回主菜单n); getchar(); getchar();/#include头文件.hshebei *xinxipaixu(shebei *top) shebei *p,*q,*s,*t; t=top; s=p=top-next; if(p=NULL) printf(内容为空,按任意键返回
17、菜单选择); getchar(); getchar(); return top; if(p-next=NULL) printf(排序完毕,返回主菜单n); return top; while(p) q=p-next; while(q) if(p-danjiaq-danjia) s-next=q-next; t-next=q; q-next=p; p=q; q=q-next; else s=s-next; q=q-next; t=t-next; s=p=p-next; printf(排序完毕,返回主菜单n); return top;/#include头文件.hshebei *xinxishanc
18、hu(shebei *top) shebei *p,*q; int a; p=top-next; q=top; if(top-next=NULL) printf(没有可删除的信息,按任意键返回菜单选择n); getchar(); getchar(); return top; printf(请输入要删除的设备编号:); scanf(%d,&a); while(p) if(a=p-bianhao) printf(n删除的设备信息如下:n); printf(设备编号 设备名称 设备种类 设备单价 购进年代 生产厂家 是否报废n); printf(%d %s %s %d %d %s %sn, p-bi
19、anhao,p-mingcheng,p-zhonglei,p-danjia,p-niandai,p-chanjia,p-baofei); if(p-next=NULL) q-next=NULL; free(p); else q-next=p-next; free(p); break; q=q-next; p=p-next; if(p=NULL) printf(此设备不存在,按任意键返回n); else printf(-删除成功,按任意键返回-n); getchar(); getchar(); return top;/#include头文件.hvoid tongmingguibing(shebe
20、i *top) shebei *p,*q,*s,*t,*j,*k; int flag; t=top; s=p=top-next; if(p=NULL) / printf(内容为空,按任意键返回上级); getchar(); getchar(); return; if(p-next=NULL) / printf(排序完毕,返回上级n); return; while(p) flag=0; q=p-next; while(q) if(strcmp(p-mingcheng,q-mingcheng)=0) s-next=q-next; t-next=q; q-next=p; p=q; q=s-next;
21、 else if(flag=0) j=q; k=s; flag+; s=s-next; q=q-next; if(flag!=0) p=j; t=s; else /printf(归并完毕,返回主菜单n); return; / printf(归并完毕,返回主菜单n); return;void fenleitongji(shebei *top) shebei *p,*q,*s; int flag,n=0; p=top-next; s=p; if(top-next=NULL) printf(内容为空,按任意键返回菜单选择); getchar(); getchar(); return; /tongmi
22、ngguibing(top); while(p) flag=0; n=1; q=p-next; while(q) if(strcmp(p-mingcheng,q-mingcheng)=0) n+; else if(flag=0) s=q; flag+; q=q-next; printf(名称为%s的设备数量为%dn,p-mingcheng,n); if(flag!=0) p=s; else return; /#include头文件.hshebei *xinxixiugai(shebei *top) shebei *p; int a,m,n; char b15; p=top-next; if(t
23、op-next=NULL) printf(没有可供修改的信息,返回菜单选择n); return top; printf(请输入修改方式:n); printf(1.按编号n2.按名称n); for(;) scanf(%d,&n); if(n!=2&n!=1) printf(输入错误,请重新输入:n); else break; if(n=1) printf(请输入要修改的设备编号:); scanf(%d,&a); while(p) if(a=p-bianhao) printf(查找到要修改的设备信息如下:n); printf(设备编号 设备名称 设备种类 设备单价 购进年代 生产厂家 是否报废n); printf(%d %s %s %d %d %s %sn, p-bianhao,p-mingcheng,p-zhonglei,p-danjia,p-nianda
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1