1、题目是: 设计一个简单仓储管理系统,要求含有基础操作功效:插入(添加)、删除、查找、修改和统计。 业务介绍 1.采购人员将采购物资清单交和财务人员,其中包含部分必需数据.财务人员据此作帐,将数据记入,并开一张票据,交和采购人员实现物资入库. 2.当有物资卖出时,即物资出库,财务人员会查阅现在这类货物库存情况,如这类货物还有存量,且有不一样出价时,财务人员会依据情况,调出对应价货物. 因为市场行情时常波动,管理人员可能会据此对物资做出对应调价. 3.当货物出现问题,需要退给供货商,并把退还货物名,数量,金额,统计下来. 4.到一定时期时候,比如月底,年底,需要将多种物资出入库,库存金额整理出来,
2、方便为管理人员提供详尽,可靠数据,为下一步制订目标方案提供依据. 2、1数据结构 用4个结构数组(或链表)来存放下述4类信息,每类信息每条统计用结构类型自定义: 1商品信息:商品编号、商品名、型号/规格、数量、进货价、销售价 2入库信息:入库编号、商品编号、入库商品名、入库数量、入库价格、总价 3出库信息:出库编号、商品编号、出库商品名、出库数量、出库价格、总价 4退货信息:退货编号、商品编号、退还货物名、退货数量、退货价格、总价 2、2设计要求 5.对以上每类信息建立数据结构 6.对以上每类信息进行插入操作 7.对以上每类信息进行删除操作 8.对以上每类信息进行修改操作 9.对以上每类信息进
3、行查找操作(查找关键字用下划线标出) 10.数据统计; i.统计入库商品总数及总价: ii.统计出库商品总数及总价: iii.统计仓库中现有商品总数及总价格: #include #include structproduct charp_num12; charname12; charspec12; intamount; intprice; ints_price; structproduct*next; ; structproduct*head; structin_product charnum12; charp_num12; charname12; intamount; intprice; in
4、tt_price; structin_product*next; ; structin_product*ihead; structout_product charnum12; charp_num12; charname12; intamount; intprice; intt_price; structout_product*next; ; structout_product*ohead; structquit_product charnum12; charp_num12; charname12; intamount; intprice; intt_price; structquit_prod
5、uct*next; ; structquit_product*qhead; intinit() head=ihead=ohead=qhead=NULL; printf(0:Quitn); printf(1:Entertheinformationofinproductn); printf(2:Entertheinformationofoutproductn); printf(3:Entertheinformationofquitproductn); printf(4:Totaltheinformationofproductn); intmenu() printf(1:insertdatan);
6、printf(2:deletedatan); printf(3:modifydatan); printf(4:selectdatan); printf(Othertoquitn); intmenu2() printf(0:Quitn); printf(1:Entertheinformationofinproductn); printf(2:Entertheinformationofoutproductn); printf(3:Entertheinformationofquitproductn); printf(4:Totaltheinformationofproductn); intinser
7、t_product() structproduct*p1,*p; p1=(structproduct*)malloc(sizeof(structproduct); p=head; if(p=NULL)/*开始没有数据*/ printf(Enterthedataofproductn); printf(Includethespbh,name,style,num,price,sale_priceofproductn); scanf(%s%s%s%d%d%d, &p1-p_num,&p1-name,&p1-spec,&p1-amount,&p1-price,&p1-s_price);head=p1;
8、head-next=NULL; return0; while(p-next!=NULL)/*把指针移到链表末端,在链表末端插入数据*/ p=p-next; p-next=p1; printf(Enterthedatan); scanf(%s%s%s%d%d%d, &p1-num,&p1-p_num,&p1-name,&p1-amount,&p1-price,&p1-t_price); p1-next=NULL; intin_insert() structin_product*p1,*p; p1=(structin_product*)malloc(sizeof(structin_product)
9、; p=ihead; if(p=NULL)/*开始没有数据*/ printf(Enterthedataofinproductn); printf(Includetherkbh,spbh,name,number,price,total_pricen); scanf(%s%s%s%d%d%d, &p1-num,&p1-p_num,&p1-name,&p1-amount,&p1-price,&p1-t_price); ihead=p1; ihead-next=NULL; return0; while(p-next!=NULL)/*把指针移到链表末端,在链表末端插入数据*/ p=p-next; p-n
10、ext=p1; printf(Enterthedatan); scanf(%s%s%s%d%d%d, &p1-num,&p1-p_num,&p1-name,&p1-amount,&p1-price,&p1-t_price); p1-next=NULL; intin_modify() charm_num12; structin_product*p; p=ihead; printf(Enterthemodifynumn); scanf(%s,&m_num); if(p=NULL)/*开始没有数据*/ printf(Sorry!Nodatacanbefoundn); return0; while(p
11、!=NULL) if(strcmp(p-num,m_num)=0) printf(Enterthenewdatawithoutnumn); scanf(%s%s%d%d%d, &p-p_num,&p-name,&p-amount,&p-price,&p-t_price); printf(Onedatahadmodifiedn); return0; p=p-next; printf(Sorry!Nonumhasfoundn); intin_select() chars_num12; structin_product*p; p=ihead; printf(Entertheselectnumn);
12、scanf(%s,&s_num); while(p!=NULL) if(strcmp(p-num,s_num)=0) printf(Thedatayouwantis:n); printf(%s%s%s%d%d%dn, p-num,p-p_num,p-name,p-amount,p-price,p-t_price); return0; p=p-next; printf(Sorry!Nonumhasfoundn); intin_delete() chard_num12; structin_product*p1,*p; p=ihead; printf(Enterthedeletenumn); sca
13、nf(%s,&d_num); if(p=NULL)/*开始没有数据*/ printf(Nodatacanbefoundn); return0; if(strcmp(p-num,d_num)=0&p-next=NULL)/*链表只有一个数据,且是要删除*/ ihead=NULL; printf(Onedatahasbeendeletedn); return0; if(strcmp(p-num,d_num)=0&p-next!=NULL)/*要删除数据在链表头上*/ ihead=ihead-next; printf(Onedatahasbeendeletedn); return0; while(p
14、-next!=NULL) p1=p-next; if(strcmp(p1-num,d_num)=0) p-next=p1-next; printf(Onedatahasbeendeletedn); return0; p=p-next; printf(Sorry!Nonumhasfoundn); intout_insert() structout_product*p1,*p; p1=(structout_product*)malloc(sizeof(structout_product); p=ohead; if(p=NULL)/*开始没有数据*/ printf(Enterthedataofout
15、productn); printf(Includetheckbh,spbh,name,number,price,total_pricen); scanf(%s%s%s%d%d%d, &p1-num,&p1-p_num,&p1-name,&p1-amount,&p1-price,&p1-t_price); ohead=p1; ohead-next=NULL; return0; while(p-next!=NULL)/*把指针移到链表末端,在链表末端插入数据*/ p=p-next; p-next=p1; printf(Enterthedatan); scanf(%s%s%s%d%d%d, &p1-
16、num,&p1-p_num,&p1-name,&p1-amount,&p1-price,&p1-t_price);p1-next=NULL; intout_modify() charm_num12; structout_product*p; p=ohead; printf(Enterthemodifynumn); scanf(%s,&m_num); if(p=NULL)/*开始没有数据*/ printf(Sorry!Nodatacanbefoundn); return0; while(p!=NULL) if(strcmp(p-num,m_num)=0) printf(Enterthenewda
17、tawithoutnumn); scanf(%s%s%d%d%d, &p-p_num,&p-name,&p-amount,&p-price,&p-t_price); printf(Onedatahadmodifiedn); return0; p=p-next; printf(Sorry!Nonumhasfoundn); intout_select() chars_num12; structout_product*p; p=ohead; printf(Entertheselectnumn); scanf(%s,&s_num); while(p!=NULL) if(strcmp(s_num,p-n
18、um)=0) printf(Thedatayouwantis:n); printf(%s%s%s%d%d%dn, p-num,p-p_num,p-name,p-amount,p-price,p-t_price); return0; p=p-next; printf(Sorry!Nonumhasfoundn); intout_delete() chard_num12; structout_product*p1,*p; p=ohead; printf(Enterthedeletenumn); scanf(%s,&d_num); if(p=NULL)/*开始没有数据*/ printf(Nodatac
19、anbefoundn); return0; if(strcmp(p-num,d_num)=0&p-next=NULL)/*链表只有一个数据,且是要删除*/ ohead=NULL; printf(Onedatahasbeendeletedn); return0; if(strcmp(p-num,d_num)=0&p-next!=NULL)/*要删除数据在链表头上*/ ohead=ohead-next; printf(Onedatahasbeendeletedn); return0; while(p-next!=NULL) p1=p-next; if(strcmp(p1-num,d_num)=0)
20、 p-next=p1-next; printf(Onedatahasbeendeletedn); return0; p=p-next; printf(Sorry!Nonumhasfoundn); intquit_insert() structquit_product*p1,*p; p1=(structquit_product*)malloc(sizeof(structquit_product); p=qhead; if(p=NULL)/*开始没有数据*/ printf(Enterthedataofquitproductn); printf(Includethethbh,spbh,name,nu
21、mber,price,total_pricen); scanf(%s%s%s%d%d%d, &p1-num,&p1-p_num,&p1-name,&p1-amount,&p1-price,&p1-t_price); qhead=p1; qhead-next=NULL; return0; while(p-next!=NULL)/*把指针移到链表末端,在链表末端插入数据*/ p=p-next; p-next=p1; printf(Enterthedatan); scanf(%s%s%s%d%d%d, &p1-num,&p1-p_num,&p1-name,&p1-amount,&p1-price,&
22、p1-t_price); p1-next=NULL; intquit_modify() charm_num12; structquit_product*p; p=qhead; printf(Enterthemodifynumn); scanf(%s,&m_num); if(p=NULL)/*开始没有数据*/ printf(Sorry!Nodatacanbefoundn); return0; while(p!=NULL) if(strcmp(p-num,m_num)=0) printf(Enterthenewdatawithoutnumn); scanf(%s%s%d%d%d, &p-p_num
23、,&p-name,&p-amount,&p-price,&p-t_price); printf(Onedatahadmodifiedn); return0; p=p-next; printf(Sorry!Nonumhasfoundn); intquit_select() chars_num12; structquit_product*p; p=qhead; printf(Entertheselectnumn); scanf(%s,&s_num); while(p!=NULL) if(strcmp(s_num,p-num)=0) printf(Thedatayouwantis:n); print
24、f(%s%s%s%d%d%dn, p-num,p-p_num,p-name,p-amount,p-price,p-t_price);return0; p=p-next; printf(Sorry!Nonumhasfoundn); intquit_delete() chard_num12; structquit_product*p1,*p; p=qhead; printf(Enterthedeletenumn); scanf(%s,&d_num); if(p=NULL)/*开始没有数据*/ printf(Nodatacanbefoundn); return0; if(strcmp(p-num,d
25、_num)=0&p-next=NULL)/*链表只有一个数据,且是要删除*/ qhead=NULL; printf(Onedatahasbeendeletedn); return0; if(strcmp(p-num,d_num)=0&p-next!=NULL)/*要删除数据在链表头上*/ qhead=qhead-next; printf(Onedatahasbeendeletedn); return0; while(p-next!=NULL) p1=p-next; if(strcmp(p1-num,d_num)=0) p-next=p1-next; printf(Onedatahasbeend
26、eletedn); return0; p=p-next; printf(Sorry!Nonumhasfoundn); inttotal() intin_num=0,in_price=0; intout_num=0,out_price=0; intnum=0,price=0; structin_product*ip; structout_product*op; structproduct*p; ip=ihead; while(ip!=NULL) in_num+=ip-amount; in_price+=ip-t_price; ip=ip-next; op=ohead; while(op!=NUL
27、L) out_num+=op-amount; out_price+=op-t_price; op=op-next; p=head; while(p!=NULL) num+=p-amount; price+=p-s_price; p=p-next; printf(Theinproductstotalnumberandtotalpriceis:n); printf(%d%dn,in_num,in_price); printf(Theoutproductstotalnumberandtotalpriceis:n); printf(%d%dn,out_num,out_price); printf(Th
28、eproductstotalnumberandtotalpriceis:n); printf(%d%dn,num,price); intin_case() intchoice; printf(Theinformationofinproduct:n); while(1) printf(Enterthechoicen); scanf(%d,&choice); switch(choice) case1:in_insert();insert_product();break; case2:in_delete();break; case3:in_modify();break; case4:in_selec
29、t();break; default:return0; menu(); intout_case() intchoice; printf(Theinformationofoutproduct:n); while(1) printf(Enterthechoicen); scanf(%d,&choice); switch(choice) case1:out_insert();break; case2:out_delete();break; case3:out_modify();break; case4:out_select();break; default:return0; menu(); intq
30、uit_case() intchoice; printf(Theinformationofquitproduct:n); while(1) printf(Enterthechoicen); scanf(%d,&choice); switch(choice) case1:quit_insert();break; case2:quit_delete();break; case3:quit_modify();break; case4:quit_select();break; default:return0; menu(); intmain() intchoice; init(); while(1) scanf(%d,&choice); switch(choice) case0:return0; case1:menu();in_case();break; case2:menu();out_case();break; case3:menu();quit_case();break; case4:total();break; menu2();