1、家电库存管理系统#include #include #include #include using namespace std;typedef struct _Nodeint kind;char model20;char brand20;int weight;int value;int amount;char date20;char factory20;struct _Node *next;Node, *LinkList;void showMenu(int n); /菜单void Create_L(LinkList head); /读取文件创建链表bool check(LinkList p1,
2、 LinkList p2); /比较 p1和 p2的品牌和类型的大小,为排序准备LinkList checkData(LinkList head, int n, LinkList /为修改和删除查找确定的结点void check_S(LinkList head, int m); /为查找函数准备的void add_L(LinkList /添加结点void save_L(LinkList head); /保存到文件里面void output(LinkList p); /输出函数void delete_L(LinkList head); /删除函数void delete_All(LinkList
3、head); /删除所有函数void modify_L(LinkList head); /修改函数void search_L(LinkList head); /查找函数void BubbleSort(LinkList head); /链表排序char str610=“,“电视机“,“电冰箱“,“空调“,“电脑“,“洗衣机“;int main()LinkList head = new Node, p;head-next = NULL;int n, i;char c;Create_L(head);doshowMenu(2);coutn;switch(n)case 1:add_L(head);bre
4、ak;case 2:delete_L(head);break;case 3:search_L(head);break;case 4:system(“cls“);p = head-next;i = 1;while(p != NULL)coutnext;if(i = 1)coutc;system(“cls“);if(c=y | c=Y)i = 1;p = head-next;while(p!=NULL)coutnext;break;case 7:save_L(head);coutc;if(c=y | c=Y)delete_All(head);coutkindnext = NULL;p-next =
5、 newNode;p = p-next;fin.close();bool check(LinkList p1, LinkList p2)/比较 p1和 p2的品牌和类型的大小,为排序准备if(p1-kind p2-kind)return true;if(!strcmp(p1-brand, p2-brand)return true;return false;void add_L(LinkList LinkList newNode = new Node;coutnewNode-kind;while(newNode-kindkind5)coutnewNode-kind;if(newNode-kind
6、5 | newNode-kindnewNode-model;coutnewNode-brand;coutnewNode-weight;coutnewNode-value;coutnewNode-amount;coutnewNode-date;coutnewNode-factory;newNode-next = NULL;LinkList pre, cur;pre = head;cur = head-next;if(head-next = NULL)head-next = newNode;elsewhile(cur!=NULL cur = cur-next;newNode-next = cur;
7、pre-next = newNode;coutnext;while(p != NULL)fout.write(char*)p, sizeof(Node);p = p-next;fout.close();void output(Node *p)/输出函数coutkindbrandmodelweightvalueamountdatefactoryn;while(n5)coutn;p = checkData(head, n, pre);if(pre=NULL)return;char c;coutc;if(c=y | c=Y)pre-next = p-next;delete p;coutnext, r
8、;while(p!=NULL)r = p-next;delete p;p = r;head-next = NULL;void modify_L(LinkList head)/修改函数int n, m;LinkList pre = NULL, p = NULL;showMenu(1);coutn;while(n5)coutn;p = checkData(head, n, pre);if(p=NULL)return;showMenu(3);coutm;coutp-kind;break;case 2:coutp-brand;break;case 3:coutp-model;break;case 4:
9、coutp-weight;break;case 5:coutp-value;break;case 6:coutp-amount;break;case 7:coutp-date;break;case 8:coutp-factory;break;case 9:coutp-kind;coutp-brand;coutp-model;coutp-weight;coutp-value;coutp-amount;coutp-date;coutp-factory;break;coutn; while(n5)coutn;check_S(head, n);void BubbleSort(LinkList head
10、)/链表排序LinkList p, p1, p2, endpt;p1 = head;for(endpt=NULL; endpt!=head; endpt = p)for(p=p1=head; p1-next-next!=endpt; p1=p1-next)if(check(p1-next, p1-next-next)p2 = p1-next-next;p1-next-next = p2-next;p2-next = p1-next;p1-next = p2;p = p1-next-next;LinkList checkData(LinkList head, int n, LinkList pre = head;char brand20;char model20;coutbrand;coutmodel;while(p!=NULL)if(p-kind=n if(p = NULL)pre = NULL;coutn;while(n5)coutn;switch(n)case 1:coutbrand;while(p!=NULL)if(p-kind=m if(i = 0)coutbrand;coutmodel;while(p!=NULL)if(p-kind=m if(p = NULL)cout“*“endl“ttt该商品没有库存了! 快进货吧!“endl;break;