1、productcpp#include #include using namespace std;class student public:string place;int numble;string name;float price;int year;int month;int day;int quantity;student *next;student *head=NULL;void addgoods(student *head) /*增加商品功能*/student *p=head;string name;int o,j;cout请输入你想要提取商品的名字name;system(cls);i
2、f(head!=NULL)do p=head; head=head-next;while(p-name!=name);cout请输入存入的数量o;j=p-quantity;p-quantity=(j+o);void extract(student *head) /* 提取功能*/student *p=head;string name;int l,j;cout请输入你想要提取商品的名字name;system(cls);if(head!=NULL)do p=head; head=head-next;while(p-name!=name);cout 你想要提取的商品为: name 库存量为: qua
3、ntityendl;cout endl;cout请输入你想要提取的商品的数量l;if(l(p-quantity)cout .endl;cout endl;cout 库存不够endl;cout endl;cout 请重新输入你想提取的数量,请不要超过库存量endl;cout endl;cout 请注意库存量为 quantityendl;cout endl;cout .endl;cout请输入:l;cout 提取成功endl;cout quantity;p-quantity=(j-l);cout 库存剩余量为 quantityendl;elsecout 提取成功endl;cout quantity
4、;p-quantity=(p-quantity-l);cout 库存剩余量为 quantityendl; bool check(string str) /*判断输入*/for(int i=0;istr.length();i+)if(stri9)&(stri!=.)return false; return true;student *create()student *p1,*p2;p1=new student;head=p1;p2=p1;string str; cout请输入商品的编号str; while(!check(str) cout输入错误,请重新输入数字编号str; p1-numble=
5、atoi(str.c_str(); if(p1-numble!=0) cout请输入商品的名字:p1-name; cout请输入商品的价格str; while(!check(str) cout输入错误,请重新输入价格str; p1-price=atoi(str.c_str(); cout请输入要存入的数量str;while(!check(str) cout输入错误,请重新输入存入数量str; p1-quantity=atoi(str.c_str(); cout请输入商品的存储日期str; while(!check(str) cout输入错误,请重新输入年份str; p1-year=atoi(s
6、tr.c_str(); cinstr; while(!check(str) cout输入错误,请重新输入月份str; p1-month=atoi(str.c_str(); cinstr; while(!check(str) cout输入错误,请重新输入daystr; p1-day=atoi(str.c_str(); cout请输入商品的产地p1-place; system(cls); else delete p1,p2=NULL,p2-next=NULL,head=NULL; return head; while(p1-numble!=0) p2=p1; p1=new student; cou
7、t请输入商品的编号:endl;cout输入0代表退出存储功能str; while(!check(str) cout输入错误,请重新输入数字编号str; p1-numble=atoi(str.c_str(); if(p1-numble!=0) cout请输入商品的名字:p1-name; cout请输入商品的价格str; while(!check(str) cout输入错误,请重新输入价格str; p1-price=atoi(str.c_str(); cout请输入要存入的数量str; while(!check(str) cout输入错误,请重新输入存入数量str; p1-quantity=ato
8、i(str.c_str(); cout请输入商品的存储日期str; while(!check(str) cout输入错误,请重新输入年份str; p1-year=atoi(str.c_str(); cinstr; while(!check(str) cout输入错误,请重新输入月份str; p1-month=atoi(str.c_str(); cinstr; while(!check(str) cout输入错误,请重新输入daystr; p1-day=atoi(str.c_str(); cout请输入商品的产地p1-place; system(cls); p2-next=p1;delete p
9、1,p2-next=NULL;return head; void insert(student *head) int num=0; string name; student *p=NULL; student *l; p=new student; while(head) l=head; head=head-next; l-next=p; p-next=NULL; cout请输入插入的内容:endl; cout请输入商品的名字p-name; cout请输入商品的编号p-numble; cout请输入商品的价格p-price; coutp-quantity; cout请输入商品的存储日期p-year
10、; cinp-month; cinp-day; cout请输入商品的产地p-place; cout添加成功endl; cout endl; void deletenode(student *head) /*删除功能*/student *l=NULL; int num;cout请输入你想删除的编号num;if(head-numble=num)l=head;head=head-next;:head=head;delete l;return;while(head!=NULL) if(head-next=NULL) cout没找到要删除的编号endl;cout next-numble=num)l=he
11、ad-next;head-next=l-next;delete l;cout成功删除endl;cout next;void show(student *beginhead) /*显示功能*/student *p=beginhead;doif(beginhead!=NULL)cout 商品的编号为: numble 商品的名字为: nameendl;cout endl;cout 商品的价格为: price 商品的产地为: placeendl;cout endl;cout 商品的库存数量为: quantity 商品的存储日期为:year-month-dayendl;cout .endl;cout n
12、ext;elsecout此链表为空endl;delete p;while(p!=NULL);void search(student *head) /*查询*/int num;student *p;cout请输入你想查找的编号:num;while(head)if(head-next=NULL) cout没找到要查询的编号numble=num) p=head; cout商品的名字为; nameendl; cout商品编号为: numbleendl;cout商品的价格为: priceendl;cout商品的库存数量为: quantityendl;cout商品的存储日期为: year-month-da
13、yendl;cout商品的产地为: placenext; p=head;int main() /*系统入口主函数*/int i,k;cout 欢迎进入仓库管理系统endl;docout endl;cout endl;cout .endl;cout endl; cout 1代表存储商品基本信息.endl;cout endl;cout 2代表删除商品基本信息.endl;cout endl;cout 3代表显示所有商品信息.endl; cout endl; cout 4代表查询商品基本信息.endl;cout endl;cout 5代表添加商品基本信息.endl;cout endl;cout 6代表
14、提取商品.endl;cout endl;cout 7代表增加已有商品的存储量endl; cout endl; cout .endl;cout endl;cout i;system(cls);switch(i)case 1: head=create(); break;case 2: deletenode(head); break;case 3: show(head); break;case 4: search(head); break;case 5: insert(head); break;case 6: extract(head); break;case 7: addgoods(head); break;cout是否继续选择功能?endl;cout1代表是,0代表否endl;cout按1将自动跳转回功能选择界面k;system(cls);while(k!=0);return 0;
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1