C语言课程设计设备管理系统Word格式.docx
《C语言课程设计设备管理系统Word格式.docx》由会员分享,可在线阅读,更多相关《C语言课程设计设备管理系统Word格式.docx(26页珍藏版)》请在冰点文库上搜索。
voidneirongxianshi(shebei*top);
voidxinxichazhao(shebei*top);
shebei*xinxixiugai(shebei*top);
shebei*xinxishanchu(shebei*top);
shebei*shebeibaofei(shebei*top);
shebei*xinxipaixu(shebei*top);
voidfenleitongji(shebei*top);
voidtongmingguibing(shebei*top);
voidbaocun(shebei*top);
//#include"
头文件.h"
voidmain()
shebei*top;
printf("
\t**********************************************************\n"
\t----------------------------------------------------------\n"
\t--------\n"
\t****欢迎进入单位仪器设备基本信息管理系统****\n"
do{top=(shebei*)malloc(sizeof(shebei));
if(top==NULL){printf("
}}while(0);
top->
next=NULL;
caidan(top);
}
voidcaidan(shebei*top)
while
(1)
{
switch(xuanze())
{
case1:
top=xinxiluru(top);
break;
case2:
neirongxianshi(top);
case3:
xinxichazhao(top);
case4:
top=xinxixiugai(top);
case5:
top=xinxishanchu(top);
case6:
top=shebeibaofei(top);
case7:
top=xinxipaixu(top);
case8:
tongmingguibing(top);
//先同名合并
fenleitongji(top);
case9:
baocun(top);
default:
printf("
退出操作,拜拜!
\n"
exit(0);
}
}
intxuanze()
intn;
\n1.增加记录\n"
2.查看信息\n"
3.查找信息\n"
4.修改信息\n"
5.删除信息\n"
6.设备报废\n"
7.信息排序\n"
8.分类统计\n"
9.保存信息\n"
按0退出\n"
for(;
;
)
scanf("
%d"
&
n);
if(n<
0||n>
9)
\n输入错误,请重新输入:
else
returnn;
shebei*shebeibaofei(shebei*top)
shebei*p;
charb[15],c;
p=top->
next;
if(top->
next==NULL)
printf("
没有信息记录,返回菜单选择\n"
returntop;
请输入要报废的设备名称:
scanf("
%s"
b);
while(p)
{
if(strcmp(b,p->
mingcheng)==0)
{
if(strcmp(p->
baofei,"
是"
)!
=0)
{
printf("
将要报废的设备信息如下:
设备编号设备名称设备种类设备单价购进年代生产厂家是否报废\n"
%d%s%s%d%d%s%s\n"
p->
bianhao,p->
mingcheng,p->
zhonglei,p->
danjia,p->
niandai,p->
chanjia,p->
baofei);
是否确认报废?
(Y/N):
scanf("
%c"
c);
if(c=='
y'
||c=='
Y'
strcpy(p->
printf("
此设备已被报废\n"
}
else
此设备已经为报废状态\n"
break;
}
p=p->
}
if(p==NULL)
没有找到该设备信息\n"
按任意键返回主菜单\n"
getchar();
returntop;
shebei*xinxiluru(shebei*top)
shebei*p,*q;
p=top;
while(p->
next!
=NULL)
p=p->
请输入设备信息:
\n输入0则结束\n"
do
feipeineicun(q);
请输入设备的编号"
q->
bianhao);
if(q->
bianhao==0)
请输入设备的名称"
q->
mingcheng);
请输入设备的种类"
zhonglei);
请输入设备的单价"
danjia);
请输入设备的年代"
niandai);
请输入设备的生产产家"
scanf("
chanjia);
请输入设备的报废情况\n"
0.没有报废\n1.已经报废\n"
for(;
{
if(n!
=0&
&
n!
=1)
printf("
输入错误,请重新输入:
else
break;
if(n==0)
strcpy(q->
否"
q->
time.year=q->
time.day=q->
time.day=0;
请输入报废时间(格式为20151012):
%d%d%d"
time.year,&
time.mouth,&
time.day);
p->
next=q;
p=q;
}while
(1);
free(q);
录入完毕,按任意键返回主菜单\n"
getchar();
voidneirongxianshi(shebei*top)
next)
设备信息如下:
else
记录为空,返回菜单\n"
while(p)
p->
voidbaocun(shebei*top)
FILE*fp;
没有东西可存!
return;
if((fp=fopen("
shebei.txt"
"
wb"
))==NULL)
exit
(1);
fwrite(p,len,1,fp);
fclose(fp);
信息已经存入文件,请继续\n"
voidxinxichazhao(shebei*top)
inta,n;
charb[15];
没有记录信息,返回菜单选择\n"
查找方式:
1.按编号查找\n2.按名称查找\n"
=2&
if(n==1)
请输入设备编号:
a);
while(p)
if(a==p->
bianhao)
{
查找到的设备信息如下:
p->
p=p->
if(n==2)
{
请输入设备名称:
{
设备编号设备名称设备种类设备单价购进年代生产厂家是否报废"
没有找到该信息\n"
shebei*xinxipaixu(shebei*top)
shebei*p,*q,*s,*t;
t=top;
s=p=top->
if(p==NULL)
内容为空,按任意键返回菜单选择"
if(p->
排序完毕,返回主菜单\n"
}
q=p->
while(q)
if(p->
danjia>
danjia)
s->
next=q->
t->
q->
next=p;
p=q;
q=q->
else
s=s->
t=t->
s=p=p->
shebei*xinxishanchu(shebei*top)
inta;
q=top;
没有可删除的信息,按任意键返回菜单选择\n"
}
请输入要删除的设备编号:
{
if(a==p->
\n删除的设备信息如下:
p->
free(p);
next=p->
q=q->
此设备不存在,按任意键返回\n"
----删除成功,按任意键返回----\n"
voidtongmingguibing(shebei*top)
shebei*p,*q,*s,*t,*j,*k;
intflag;
//printf("
内容为空,按任意键返回上级"
排序完毕,返回上级\n"
flag=0;
if(strcmp(p->
mingcheng,q->
mingcheng)==0)
q=s->
if(flag==0)
j=q;
k=s;
flag++;
}
if(flag!
p=j;
t=s;
//printf("
归并完毕,返回主菜单\n"
return;
//printf("
return;
voidfenleitongji(shebei*top)
shebei*p,*q,*s;
intflag,n=0;
s=p;
//tongmingguibing(top);
n=1;
n++;
s=q;
flag++;
q=q->
名称为%s的设备数量为%d\n"
p->
mingcheng,n);
p=s;
shebei*xinxixiugai(shebei*top)
inta,m,n;
没有可供修改的信息,返回菜单选择\n"
请输入修改方式:
1.按编号\n2.按名称\n"
请输入要修改的设备编号:
查找到要修改的设备信息如下:
nianda