c语言--仓库管理系统(5) 8页

  • 45.00 KB
  • 2022-05-16 18:34:19 发布

c语言--仓库管理系统(5)

  • 8页
  • 当前文档由用户上传发布,收益归属用户
  1. 1、本文档共5页,可阅读全部内容。
  2. 2、本文档内容版权归属内容提供方,所产生的收益全部归内容提供方所有。如果您对本文有版权争议,可选择认领,认领后既往收益都归您。
  3. 3、本文档由用户上传,本站不保证质量和数量令人满意,可能有诸多瑕疵,付费之前,请仔细先通过免费阅读内容等途径辨别内容交易风险。如存在严重挂羊头卖狗肉之情形,可联系本站下载客服投诉处理。
  4. 文档侵权举报电话:19940600175。
#include#include#includetypedefstruct{intno;charname[5];intnumber;}Data;typedefstructnode{Datainform;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);do{cout<<"n----------------------------------"<<"请选择相应的操作"<<"------------------------------n"<<"1.........录入货物信息"<>option;switch(option) {case0:break;case1:L=Creat_LinkList(L);break;case2:{intn1;LinkListL1;L1=(LNode*)malloc(sizeof(LNode));cout<<"n键入0退出查找。n";do{cout<<"n输入要查找的货号:";cin>>n1;if(n1==0)break;L1=Search_Data(n1,L);if(L1==NULL){cout<<"n找不到指定的货物!!!!n";}else{cout<<"------------------------------------n"<<"货物代号"<inform.no<inform.name<inform.number<>d.no; L1=Search_Data(d.no,L);if(d.no==0)break;if(L1!=NULL){cout<<"n仓库中已存在要加入的货物,n"<<"只需输入加入的数量:";cin>>d.number;}else{cout<<"n输入货物名称及数量:";cin>>d.name>>d.number;}L=In_Data(d,L);}while(1);break;}case4:{LinkListL1;L1=(LNode*)malloc(sizeof(LNode));cout<<"n键入0退出提取货物。n";do{intNo,number;cout<<"n输入要提取货号:";cin>>No;if(No==0)break;L1=Search_Data(No,L);if(L1==NULL){cout<<"该货物信息不存在!!!n";continue;}cout<<"------------------------------------n"<<"货物代号"<inform.no<inform.name<inform.number<>number;Out_Data(No,number,L); }while(1);break;}case5:{Print_LinkList(L);break;}default:cout<<"无效操作!!";break;}}while(option);return0;}voidOnit_LinkList(LinkListL){L->next=NULL;}LinkListCreat_LinkList(LinkListL){LNode*s,*r=L;cout<<"键入0退出录入。n";do{cout<<"n输入货号:";s=(LNode*)malloc(sizeof(LNode));cin>>s->inform.no;if(s->inform.no==0){free(s);break;}if(r->inform.no==s->inform.no){cout<<"n货号重复!!!!n";continue;}cout<<"n输入货物名称及数量:";cin>>s->inform.name>>s->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";else{cout<<"------------------------------------n"<<"货物代号"<next;cout<inform.no<inform.name<inform.number<next!=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;i<6;i++){p->inform.name[i]=d.name[i];}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);do{p=(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;else{ charp;cout<<"n该货物库存不足,是否提取(Y/N):";cin>>p;if(p=="y"||p=="Y"){cout<<"n货物"<inform.name<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.no>r->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.noinform.no)p=r;r=r->next;}returnp;}