数据结构课程设计公司管理系统_第1页
数据结构课程设计公司管理系统_第2页
数据结构课程设计公司管理系统_第3页
数据结构课程设计公司管理系统_第4页
数据结构课程设计公司管理系统_第5页
已阅读5页,还剩16页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、#include#include#include/顾客链表,用于存放顾客名字、电话和该顾客所有订单typedef struct CustomerList char name15,tel15; char ID15; int produce_num; struct CustomerList* next; /struct IndentList* Indent;Customer, *PCustomer;/产品链表,用于存放产品信息typedef struct ProduceList char name15; int price; int num; struct ProduceList* next; s

2、truct CustomerList* Customer; struct SupplierList* Supplier;Produce, *PProduce;/供应商链表,用于存放供应商信息以及该供应商所供应的订单信息typedef struct SupplierList char name15, tel15; char ID15; int produce_num; struct SupplierList* next; /struct IndentList* Indent;Supplier, *PSupplier;/订单链表,用于存放订单信息,该订单的顾客、产品及供应商typedef stru

3、ct IndentList char number15; struct ProduceList produce; struct CustomerList Customer;/一个订单顾客只有一个 struct SupplierList Supplier;/供应商也只有一个 struct IndentList* next;Indent, *PIndent;/头节点Customer Customerhead;Produce Producehead;Supplier Supplierhead; Indent Indenthead;/头指针struct CustomerList* p_Customer

4、head = &Customerhead;struct ProduceList* p_Producehead = &Producehead;struct SupplierList* p_Supplierhead = &Supplierhead;struct IndentList* p_Indenthead = &Indenthead;/*/在顾客链表尾部添加数据void Customer_append() int flag = 1; PCustomer newCustomer = (PCustomer)malloc(sizeof(Customer); printf(请输入要添加的顾客信息n);

5、 printf(姓名: ); scanf(%s, newCustomer-name); /printf(%sn, newCustomer-name); printf(电话: ); scanf(%s, newCustomer-tel); /printf(%sn, newCustomer-tel); printf(ID: ); scanf(%s, newCustomer-ID); /printf(%sn, newCustomer-ID); newCustomer-next = NULL; newCustomer-produce_num = 0;/ newCustomer-Indent = NULL

6、; /查找最后一个节点 PCustomer tmp = p_Customerhead; while (tmp-next) tmp = tmp-next; if (strcmp(tmp-ID, newCustomer-ID) = 0) flag = 0; free(newCustomer); break; if (flag) tmp-next = newCustomer; printf(添加完成n); else printf(已存在该客户信息n); /在顾客链表中查找顾客int Customer_find(char* ID,PCustomer Customer) int pos = 1; PCu

7、stomer tmp = p_Customerhead; while (tmp = tmp-next) if (strcmp(tmp-ID, ID)=0) strcpy(Customer-name , tmp-name); strcpy(Customer-tel , tmp-tel); return pos; pos+; return -1;/删除顾客int Customer_remove(char* ID) PCustomer tmp = p_Customerhead; PCustomer node; while (tmp-next) if (strcmp(tmp-next-ID, ID)

8、= 0) node = tmp-next; tmp-next = tmp-next-next; printf(删除顾客%sn, node-name); free(node); node = NULL; printf(删除成功n); return 1; printf(删除失败n); return 0;/展示顾客void Customer_show(char*ID) PCustomer tmp = p_Customerhead; while (tmp = tmp-next) if (strcmp(tmp-ID, ID) = 0) printf(顾客姓名:%s, tmp-name); printf(

9、顾客ID:%s, tmp-ID); printf(顾客电话:%sn, tmp-tel); return; printf(不存在该顾客n);/展示所有顾客void Customer_showall() PCustomer tmp = p_Customerhead; while (tmp = tmp-next) printf(顾客姓名:%s, tmp-name); printf(顾客ID:%s, tmp-ID); printf(顾客电话:%sn, tmp-tel); /修改顾客信息void Customer_change(char* ID) PCustomer tmp = p_Customerhe

10、ad; while (tmp = tmp-next) if (strcmp(tmp-ID, ID) = 0) printf(找到需要修改的顾客n); printf(顾客姓名:%s, tmp-name); printf(顾客ID:%s, tmp-ID); printf(顾客电话:%sn, tmp-tel); printf(请输入要修改的用户的信息n姓名:); scanf(%s, tmp-name); printf(电话:n); scanf(%s, tmp-tel); printf(修改完成:n); return; printf(修改失败:n);/*/在产品链表尾部添加数据void Produce

11、_append() int flag = 1; PProduce newProduce = (PProduce)malloc(sizeof(Produce); PCustomer newCustomer = (PCustomer)malloc(sizeof(Customer); PSupplier newSupplier = (PSupplier)malloc(sizeof(Supplier); printf(请输入要添加的产品信息n); printf(产品名: ); scanf(%s, newProduce-name); printf(价格: ); scanf(%d, &newProduce

12、-price); newProduce-next = NULL; newCustomer-next = NULL; newSupplier-next = NULL; newProduce-num = 0; /strcpy(newProduce-Customer-ID, ); newProduce-Customer = newCustomer; /strcpy(newProduce-Supplier-ID , ); newProduce-Supplier = newSupplier; /查找最后一个节点 PProduce tmp = p_Producehead; while (tmp-next)

13、 tmp = tmp-next; if (strcmp(tmp-name, newProduce-name) = 0) flag = 0; free(newProduce); break; if (flag) tmp-next = newProduce; printf(添加完成n); else printf(已存在该产品信息n); /在产品链表中查找产品int Produce_find(char* name,PProduce p_Profucehead) int pos = 1; PProduce tmp = p_Profucehead; while (tmp = tmp-next) if (

14、strcmp(tmp-name ,name)=0) return pos; pos+; return -1;/返回产品价格int Produce_price(char* name) PProduce tmp = p_Producehead; while (tmp = tmp-next) if (strcmp(tmp-name, name) = 0) return tmp-price; return -1;/添加购买该产品的顾客int Produce_Customer(char* name, PCustomer _Customer) PProduce tmp = p_Producehead; P

15、Customer newCustomer = (PCustomer)malloc(sizeof(Customer); PCustomer cus_tmp; while (tmp = tmp-next) /找产品 if (strcmp(tmp-name, name) = 0) int flag = 1; cus_tmp = tmp-Customer; /找是否已有该顾客 while (cus_tmp-next) if (strcmp(cus_tmp-next-ID, _Customer-ID) = 0) cus_tmp = cus_tmp-next; flag = 0; break; cus_t

16、mp = cus_tmp-next; if (flag) strcpy(newCustomer-ID, _Customer-ID); strcpy(newCustomer-name, _Customer-name); strcpy(newCustomer-tel, _Customer-tel); newCustomer-next = NULL; newCustomer-produce_num = _Customer-produce_num; cus_tmp-next = newCustomer; printf(顾客 %s %s %s %d, newCustomer-ID, newCustome

17、r-name, newCustomer-tel, newCustomer-produce_num); return 1; else cus_tmp-produce_num += _Customer-produce_num; printf(顾客%s %s %s %d, cus_tmp-ID, cus_tmp-name, cus_tmp-tel, cus_tmp-produce_num); free(newCustomer); return 0; return 0;/添加提供该产品的供应商int Produce_Supplier(char* name, PSupplier _Supplier) P

18、Produce tmp = p_Producehead; PSupplier newSupplier = (PSupplier)malloc(sizeof(Supplier); PSupplier sup_tmp; while (tmp = tmp-next) /找产品 if (strcmp(tmp-name, name) = 0) int flag = 1; sup_tmp = tmp-Supplier; /找是否已有该供应商 while (sup_tmp-next) if (strcmp(sup_tmp-next-ID, _Supplier-ID) = 0) sup_tmp = sup_t

19、mp-next; flag = 0; break; sup_tmp = sup_tmp-next; if (flag) strcpy(newSupplier-ID, _Supplier-ID); strcpy(newSupplier-name, _Supplier-name); strcpy(newSupplier-tel, _Supplier-tel); newSupplier-next = NULL; newSupplier-produce_num = _Supplier-produce_num; sup_tmp-next = newSupplier; printf(供应商%s %s %s

20、 %d, newSupplier-ID, newSupplier-name, newSupplier-tel, newSupplier-produce_num); return 1; else sup_tmp-produce_num += _Supplier-produce_num; printf(供应商%s %s %s %d, sup_tmp-ID, sup_tmp-name, sup_tmp-tel, sup_tmp-produce_num); free(newSupplier); return 0; return 0;/删除产品int Produce_remove(char* name)

21、 PProduce tmp = p_Producehead; PProduce node; while (tmp-next) if (strcmp(tmp-next-name, name) = 0) node = tmp-next; tmp-next = tmp-next-next; printf(删除产品%s, node-name); free(node); node = NULL; return 1; return 0;/展示产品及顾客供应商信息void Produce_show(char* name) PProduce tmp = p_Producehead; PCustomer tmp

22、_customer; PSupplier tmp_supplier; while (tmp = tmp-next) if (strcmp(tmp-name, name) = 0) printf(产品名:%s, name); tmp_customer = tmp-Customer; while (tmp_customer=tmp_customer-next) printf(客户姓名:%s,客户ID:%s,客户电话:%sn, tmp_customer-name, tmp_customer-ID, tmp_customer-tel); tmp_supplier = tmp-Supplier; whi

23、le (tmp_supplier = tmp_supplier-next) printf(供应商姓名:%s,供应商ID:%s,供应商电话:%sn, tmp_supplier-name, tmp_supplier-ID, tmp_supplier-tel); return; printf(不存在该产品n);/修改产品信息void Produce_change(char* name) PProduce tmp = p_Producehead; while (tmp = tmp-next) if (strcmp(tmp-name, name) = 0) printf(找到需要修改的产品n); pri

24、ntf(产品名称:%s, tmp-name); printf(产品价格:%d, tmp-price); printf(请输入要修改的用户的信息n价格:); scanf(%d, &tmp-price); printf(修改完成:n); return; printf(修改失败:n);/展示所有产品及顾客供应商信息void Produce_showall() PProduce tmp = p_Producehead; PCustomer tmp_customer; PSupplier tmp_supplier; while (tmp = tmp-next) printf(产品名:%s, tmp-na

25、me); tmp_customer = tmp-Customer; while (tmp_customer = tmp_customer-next) printf(客户姓名:%s,客户ID:%s,客户电话:%sn, tmp_customer-name, tmp_customer-ID, tmp_customer-tel); tmp_supplier = tmp-Supplier; while (tmp_supplier = tmp_supplier-next) printf(供应商姓名:%s,供应商ID:%s,供应商电话:%sn, tmp_supplier-name, tmp_supplier

26、-ID, tmp_supplier-tel); /*/在供应商链表尾部添加数据void Supplier_append() int flag = 1; PSupplier newSupplier = (PSupplier)malloc(sizeof(Supplier); printf(请输入要添加的产品信息n); printf(供应商名字: ); scanf(%s, newSupplier-name); printf(供应商电话: ); scanf(%s, newSupplier-tel); printf(供应商ID: ); scanf(%s, newSupplier-ID); newSupp

27、lier-next = NULL; newSupplier-produce_num = 0; /newSupplier-Indent = NULL; /查找最后一个节点 PSupplier tmp = p_Supplierhead; while (tmp-next) tmp = tmp-next; if (strcmp(tmp-ID, newSupplier-ID) = 0) flag = 0; free(newSupplier); break; if (flag) tmp-next = newSupplier; printf(添加完成n); else printf(已存在该供应商信息n);

28、/在供应商链表中查找供应商int Supplier_find(char* ID,PSupplier supplier) int pos = 1; PSupplier tmp = p_Supplierhead; while (tmp = tmp-next) if (strcmp(tmp-ID , ID)=0) strcpy(supplier-name, tmp-name); strcpy(supplier-tel, tmp-tel); return pos; pos+; return -1;/删除供应商int Supplier_remove(char* ID) PSupplier tmp = p

29、_Supplierhead; PSupplier node; while (tmp-next) if (strcmp(tmp-next-ID, ID) = 0) node = tmp-next; tmp-next = tmp-next-next; printf(删除供应商%s, node-name); free(node); node = NULL; return 1; return 0;/展示供应商信息void Supplier_show(char*ID) PSupplier tmp = p_Supplierhead; while (tmp = tmp-next) if (strcmp(tm

30、p-ID, ID) = 0) printf(供应商姓名:%s, tmp-name); printf(供应商ID:%s, tmp-ID); printf(供应商电话:%sn, tmp-tel); return; printf(不存在该供应商n);/修改供应商信息void Supplier_change(char* ID) PSupplier tmp = p_Supplierhead; while (tmp = tmp-next) if (strcmp(tmp-ID, ID) = 0) printf(找到需要修改的供应商n); printf(供应商姓名:%s, tmp-name); printf(

31、供应商ID:%s, tmp-ID); printf(供应商电话:%sn, tmp-tel); printf(请输入要修改的供应商的信息n姓名:); scanf(%s, tmp-name); printf(电话:n); scanf(%s, tmp-tel); printf(修改完成:n); return; printf(不存在该供应商n);/展示所有供应商信息void Supplier_showall() PSupplier tmp = p_Supplierhead; while (tmp = tmp-next) printf(供应商姓名:%s, tmp-name); printf(供应商ID:

32、%s, tmp-ID); printf(供应商电话:%sn, tmp-tel); /*/在订单链表尾部添加数据void Indent_append() int flag = 1; int num; PIndent newIndent = (PIndent)malloc(sizeof(Indent); newIndent-next = NULL; PProduce newProduce = (PProduce)malloc(sizeof(Produce); printf(请输入要添加的订单信息n); printf(订单号: ); scanf(%s, newIndent-number); prin

33、tf(供应商ID: ); while (scanf(%s, newIndent-Supplier.ID) /判断是否存在该供应商 if (Supplier_find(newIndent-Supplier.ID,&newIndent-Supplier)=-1) printf(不存在该供应商,请重新输入); continue; break; newIndent-Sduce_num = 0; printf(客户ID: ); while (scanf(%s, newIndent-Customer.ID) /判断是否存在该客户 if (Customer_find(newIndent

34、-Customer.ID,&newIndent-Customer)=-1) printf(不存在该客户,请重新输入); continue; /printf(%s %s %s, newIndent-C, newIndent-Customer.tel, newIndent-Customer.ID); break; newIndent-Cduce_num = 0; /查找最后一个节点 PIndent tmp = p_Indenthead; while (tmp-next) tmp = tmp-next; if (strcmp(tmp-number, ne

35、wIndent-number) = 0) flag = 0; free(newIndent); free(newProduce); break; if (flag) /订单不存在,添加订单中物品信息 printf(产品类型数:); scanf(%d, &num); newProduce = &newIndent-produce; newProduce-next = NULL; /取订单表中的produce PProduce tmpProduce = newProduce; for (int i = 0; i next = NULL; printf(产品名:); scanf(%s, NodePr

36、oduce-name); printf(产品数量:); scanf(%d, &NodeProduce-num); if (Produce_find(NodeProduce-name,p_Producehead) = -1) printf(不存在该产品,是否重新输入?(y/n); char ch2; scanf(%s, ch); if (strcmp(ch, y)=0) i-; free(NodeProduce); continue; if (Produce_find(NodeProduce-name, newProduce) != -1) printf(已输入过该产品,是否重新输入?(y/n)

37、; char ch2; scanf(%s, ch); if (strcmp(ch, y)=0) i-; free(NodeProduce); continue; NodeProduce-price = Produce_price(NodeProduce-name);/添加价格 newIndent-Cduce_num = NodeProduce-num; newIndent-Sduce_num = NodeProduce-num; Produce_Customer(NodeProduce-name, &newIndent-Customer);/添加顾客

38、 Produce_Supplier(NodeProduce-name, &newIndent-Supplier);/添加供应商 tmpProduce-next = NodeProduce; tmpProduce = tmpProduce-next; /printf(%s %d %d, tmpProduce-name, tmpProduce-num, tmpProduce-price); /newIndent-produce = newProduce; tmp-next = newIndent; printf(添加完成n); else printf(已存在该订单n); /在订单链表中查找订单in

39、t Indent_find(char* number) int pos = 1; PIndent tmp = p_Indenthead; while (tmp = tmp-next) if (strcmp(tmp-number, number) = 0) return pos; pos+; return -1;/删除订单int Indent_remove(char* number) PIndent tmp = p_Indenthead; PIndent node; PProduce produce_tmp; /在订单链表中寻找需删除的节点 while (tmp-next) if (strcmp(tmp-next-number, number) = 0)/找到节点 node = tmp-next;/中间节点 tmp-next = tmp-next-next;/改变next节点位置 printf(删除订单%s, node-number); produce_tmp = &node-produce;/取中间节点的produce元素 /扫一遍中间节点的produce while (produce_tmp = produce_tmp-next) /更新p_Producehead链表中每个produce的顾客和供应商的值 PCus

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论