您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 市场营销 > 产品进销存管理系统--代码
#include<stdio.h>#include<stdlib.h>#include<string.h>#defineok1#defineerror0#defineoverflow0#defineSQMOUNTLINK_INIT_SIZE100#defineSQMOUNTLINKINCREMENT10typedefstructdate{intyear;intmonth;intday;}date;//ÈÕÆÚtypedefstructproductlnode{charpname[30];//²úÆ·Ãû³Æinttotalquantity;//²úÆ·×ÜÁ¿dategoodsdate;//½ø»õÈÕÆÚintsalesquantity;//Ïû³ýÊýÁ¿datesalestime;//ÏúÊÛʱ¼ästructproductlnode*nextproduct;}productlnode,*plinklist;typedefstructkindlnode{productlnode*firstproduct;charpkindname[30];}kindlnode;typedefstruct{kindlnode*kindelem;intlength;intlistsize;}sqmountlink;intInitMountList(sqmountlink&L){//³õʼ»¯Ò»¸ö¿ÕµÄ˳Ðò±í¹Ò½ÓÁ´±íLinti;L.kindelem=(kindlnode*)malloc(SQMOUNTLINK_INIT_SIZE*sizeof(kindlnode));if(!L.kindelem)exit(overflow);L.length=0;L.listsize=SQMOUNTLINK_INIT_SIZE;for(i=0;i<L.listsize;i++){(L.kindelem[i]).firstproduct=NULL;}returnok;}//InitMountListintKindInsert(sqmountlink&L,intn){//Ïò˳Ðò±í¹Ò½ÓÁ´±íLÖÐÌí¼ÓNÀà²úÆ·inti;kindlnode*newbase;if(L.length+n>=L.listsize){newbase=(kindlnode*)realloc(L.kindelem,(L.listsize+n)*sizeof(kindlnode));if(!newbase)exit(overflow);L.kindelem=newbase;L.listsize+=n;}printf("ÐèÌí¼ÓµÄ²úÆ·ÀàÃû³Æ£º\n");for(i=0;i<n;i++){scanf("%s",&L.kindelem[L.length].pkindname);L.kindelem[L.length].firstproduct=NULL;L.length++;}returnok;}//KindInsertintProductInsert(sqmountlink&L,charpkindname2[],intn){//Ïò˳Ðò±í¹Ò½ÓÁ´±íLµÄij²úÆ·ÀàÖÐÌí¼ÓN¸ö²úÆ·plinklistp,q;intk,j;for(k=0;k<L.length;k++){if(strcmp((L.kindelem[k]).pkindname,pkindname2)!=0)continue;elsebreak;}if(L.kindelem[k].firstproduct==NULL){q=(plinklist)malloc(sizeof(productlnode));printf("ÊäÈë´Ë²úÆ·ÀàËùº¬²úÆ·µÄ²úÆ·Ãû³Æ¡¢×ÜÁ¿¡¢½ø»õÈÕÆÚ¡¢ÏúÊÛÊýÁ¿¡¢ÏúÊÛʱ¼ä£º\n");scanf("%s%d%d,%d,%d%d%d,%d,%d",&(q->pname),&(q->totalquantity),&((q->goodsdate).year),&((q->goodsdate).month),&((q->goodsdate).day),&(q->salesquantity),&((q->salestime).year),&((q->salestime).month),&((q->salestime).day));q->nextproduct=NULL;(L.kindelem[k]).firstproduct=q;for(j=1;j<n;j++){p=(plinklist)malloc(sizeof(productlnode));printf("ÊäÈë´Ë²úÆ·ÀàËùº¬²úÆ·µÄ²úÆ·Ãû³Æ¡¢×ÜÁ¿¡¢½ø»õÈÕÆÚ¡¢ÏúÊÛÊýÁ¿¡¢ÏúÊÛʱ¼ä£º\n");\scanf("%s%d%d,%d,%d%d%d,%d,%d",&(p->pname),&(p->totalquantity),&((p->goodsdate).year),&((p->goodsdate).month),&((p->goodsdate).day),&(p->salesquantity),&((p->salestime).year),&((p->salestime).month),&((p->salestime).day));p->nextproduct=q->nextproduct;q->nextproduct=p;q=p;}}else{for(q=L.kindelem[k].firstproduct;;q=q->nextproduct){if(!(q->nextproduct))break;}printf("ÐèÌí¼Ó²úÆ·µÄÃû³Æ¡¢×ÜÁ¿¡¢½ø»õÈÕÆÚ¡¢ÏúÊÛÊýÁ¿¡¢ÏúÊÛʱ¼ä£º\n");for(j=0;j<n;j++){p=(plinklist)malloc(sizeof(productlnode));scanf("%s%d%d,%d,%d%d%d,%d,%d",&(p->pname),&(p->totalquantity),&((p->goodsdate).year),&((p->goodsdate).month),&((p->goodsdate).day),&(p->salesquantity),&((p->salestime).year),&((p->salestime).month),&((p->salestime).day));p->nextproduct=q->nextproduct;q->nextproduct=p;q=p;}}returnok;}//ProductInsertvoidProQuantity_add(sqmountlink&L,charpkindname1[],charpname1[],intn){//Ìí¼Ó˳Ðò±í¹Ò½ÓÁ´±íLµÄij²úÆ·ÀàÖеÄij²úÆ·µÄ×ÜÁ¿£¬ÇÒÐèÌí¼ÓµÄ²úÆ·×ÜÁ¿Îªninti,k;plinklistp;for(i=0;i<L.length;i++){if(strcmp((L.kindelem[i]).pkindname,pkindname1)!=0)continue;elsebreak;}if(i<L.length){for(p=L.kindelem[i].firstproduct;p!=NULL;p=p->nextproduct){k=strcmp(p->pname,pname1);if(k==0){p->totalquantity=p->totalquantity+n;printf("²é¿´Ìí¼Óºó²úÆ·µÄ¸÷ÏîÊä³ö£º%s%d%d,%d,%d%d%d,%d,%d\n",p->pname,p->totalquantity,(p->goodsdate).year,(p->goodsdate).month,(p->goodsdate).day,p->salesquantity,(p->salestime).year,(p->salestime).month,(p->salestime).day);}}}}//ProQuantity_addvoidProQuantity_subtract(sqmountlink&L,charpkindname4[],charpname4[],intn){//Ìí¼Ó˳Ðò±í¹Ò½ÓÁ´±íLµÄij²úÆ·ÀàÖеÄij²úÆ·Ïú³öÊýÁ¿£¬ÇÒÏú³öµÄÊýÁ¿ninti,k;plinklistp;for(i=0;i<L.length;i++){if(strcmp((L.kindelem[i]).pkindname,pkindname4)!=0)continue;elsebreak;}if(i<L.length){for(p=L.kindelem[i].firstproduct;p!=NULL;p=p->nextproduct){k=strcmp(p->pname,pname4);if(k==0){p->salesquantity=p->salesquantity+n;printf("²é¿´Ìí¼Óºó²úÆ·µÄ¸÷ÏîÊä³ö£º%s%d%d,%d,%d%d%d,%d,%d\n",p->pname,p->totalquantity,(p->goodsdate).year,(p->goodsdate).month,(p->goodsdate).day,p->salesquantity,(p->salestime).year,(p->salestime).month,(p->salestime).day);}}}}//ProQuantity_subtractvoidVisit(sqmountlink&L,charpkindname3[],charpname3[]){//ÔÚ˳Ðò±í¹Ò½ÓÁ´±íLÖУ¬²éѯÊôÓÚij²úÆ·ÀàµÄij²úÆ·µÄ¸÷ÏîÐÅÏ¢inti,k;plinklistp;for(i=0;i<L.length;i++){if(strcmp((L.kindelem[i]).pkindname,pkindname3)!=0)continue;elsebreak;}if(i<L.length){for(p=L.kindelem[i].firstproduct;p!=NULL;p=p->nextproduct){k=strcmp(p->pname,pname3);if(k==0)break;}if(k!=0)printf("´Ë²úÆ·²»´æÔÚ£º\n&quo
本文标题:产品进销存管理系统--代码
链接地址:https://www.777doc.com/doc-5753162 .html