资源预览内容
第1页 / 共21页
第2页 / 共21页
第3页 / 共21页
第4页 / 共21页
第5页 / 共21页
第6页 / 共21页
第7页 / 共21页
第8页 / 共21页
第9页 / 共21页
第10页 / 共21页
亲,该文档总共21页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
.#include#include#includetypedefstructintno;charname5;intnumber;Data;typedefstructnodeDatainform;structnode*next;LNode,*LinkList;voidOnit_LinkList(LinkListL);LinkListCreat_LinkList(LinkListL);voidPrint_LinkList(LNode*L);LinkListSearch_Data(intNo,LinkListL);LinkListIn_Data(Datad,LinkListL);voidOut_Data(intNo,intnumber,LinkListL);LinkListSort_LinkList(LinkListL);LNode*Compare_NO(LinkListL);LNode*Mix(LinkListL);intmain()intoption;LNode*L;L=(LNode*)malloc(sizeof(LNode);Onit_LinkList(L);docoutn-请选择相应的操作-n1.录入货物信息endl2.查找货物并输出相应信息endl3.加入货物endl4.提取货物endl5.输出货物信息endl0.退出仓库管理系统option;switch(option)case0:break;case1:L=Creat_LinkList(L);break;case2:intn1;LinkListL1;L1=(LNode*)malloc(sizeof(LNode);coutn键入0退出查找。n;docoutn1;if(n1=0)break;L1=Search_Data(n1,L);if(L1=NULL)coutn找不到指定的货物!n;elsecout-n货物代号setw(15)货物名称setw(15)货物数量endlinform.nosetw(18)inform.namesetw(18)inform.numberendl;while(n1);break;case3:LinkListL1;L1=(LNode*)malloc(sizeof(LNode);cout键入0退出加入货物。n;doDatad;coutd.no;L1=Search_Data(d.no,L);if(d.no=0)break;if(L1!=NULL)coutn仓库中已存在要加入的货物,nd.number;elsecoutd.named.number;L=In_Data(d,L);while(1);break;case4:LinkListL1;L1=(LNode*)malloc(sizeof(LNode);coutn键入0退出提取货物。n;dointNo,number;coutNo;if(No=0)break;L1=Search_Data(No,L);if(L1=NULL)cout该货物信息不存在!n;continue;cout-n货物代号setw(15)货物名称setw(15)货物数量endlinform.nosetw(18)inform.namesetw(18)inform.numberendl;coutnumber;Out_Data(No,number,L);while(1);break;case5:Print_LinkList(L);break;default:coutnext=NULL;LinkListCreat_LinkList(LinkListL)LNode*s,*r=L;cout键入0退出录入。n;docouts-inform.no;if(s-inform.no=0)free(s);break;if(r-inform.no=s-inform.no)coutn货号重复!n;continue;couts-inform.names-inform.number;r-next=s;r=s;while(1);if(r!=NULL)r-next=NULL;L=Sort_LinkList(L);returnL;voidPrint_LinkList(LNode*L)LNode*r=L;if(L-next=NULL)cout仓库中无货物n;elsecout-n货物代号setw(15)货物名称setw(15)货物数量next;coutinform.nosetw(18)inform.namesetw(18)inform.numbernext!=NULL);LinkListSearch_Data(intNo,LinkListL)LinkListr;r=L-next;while(r!=NULL&r-inform.no!=No)r=r-next;returnr;LinkListIn_Data(Datad,LinkListL)LinkListL1;L1=(LNode*)malloc(sizeof(LNode);L1=Search_Data(d.no,L);if(L1=NULL)LNode*r,*p,*s;r=L-next;s=L;p=(LNode*)malloc(sizeof(LNode);p-inform.no=d.no;for(inti=0;iinform.namei=d.namei;p-inform.number=d.number;while(r-inform.nonext;while(s-next!=r)s=s-next;p-next=s-next;s-next=p;elseL1-inform.number+=d.number;returnL;LinkListSort_LinkList(LinkListL)LinkListnew_list;LNode*r,*p,*mix;new_list=(LNode*)malloc(sizeof(LNode);new_list-next=NULL;r=new_list;mix=Mix(L);dop=(LNode*)malloc(sizeof(LNode);p=Compare_NO(L);r-next=p;r=p;while(p-inform.noinform.no);if(r!=NULL)r-next=NULL;L=new_list;returnL;voidOut_Data(intNo,intnumber,LinkListL)LinkListL1;L1=(LNode*)malloc(sizeof(LNode);L1=Search_Data(No,L);if(L1-inform.number=number)L1-inform.number-=number;elsecharp;coutp;if(p=y|p=Y)coutn货物inform.nameendl提取了inform.number件,还需inform.number件才能满足您的要求inform.number=0;LNode*Compare_NO(LinkListL)LNode*r,*p,*s;s=(LNode*)malloc(sizeof(LNode);p=L-next;if(p-next=NULL)returnp;r=p-next;while(r!=NULL)if(p-inform.nor-inform.no)p=r;r=r-next;*s=*p;while(L-next!=p)L=L-next;if(p-next=NULL)L-next=NULL;elseL-next=p-next;free(p);returns;LNode*Mix(LinkListL)LNode*r,*p,*s;s=(LNode*)malloc(sizeof(LNode);p=L-next;if(p-next=NULL)returnp;r=p-next;while(r!=NULL)if(p-inform.noinfor
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号