1、float price_in;float price_out;int num_in;int num_now;int num_sold;float win;float percent;struct shop *next;int n=0;void main(void)void auto1(struct shop *h_p);int menu1(struct shop *h_p);void print1(void);void assistant(struct shop *head);int password(void);int menu2(struct shop *h_p);void print2(
2、void);void creat(struct shop *h_p);void rewrite(struct shop *h_p);void insert(struct shop *h_p);void deleat(struct shop *h_p);void search(struct shop *h_p);void printall(struct shop *h_p);void save(struct shop *head);void password_set(void);int password_exi(struct shop *h_p);int data_exi(struct shop
3、 *h_p);void load(struct shop *h_p);struct shop *addbuild(struct shop *h_p);void sort0(struct shop *h_p);int search1(struct shop *h_p,char a30);void sort1(struct shop *h_p);void sort2(struct shop *h_p);void sort3(struct shop *h_p);void print3(void);void password_create(void);int a;struct shop *head,*
4、h_p;head=NULL;h_p=&head;auto1(h_p);doa=menu1(h_p);while(a!=3);system(cls);printf(谢谢使用_getch();int menu1(struct shop *h_p)int a,b;struct shop *head;head=*h_p;print1();scanf(%d,&a);putchar(ngetchar();switch(a)case 1:assistant(head);break;case 2:if(password()b=menu2(h_p);while(b!=9);default:if(a!=3)ret
5、urn(a);int menu2(struct shop *h_p)int b;char a;print2();b);switch(b) creat(h_p);rewrite(h_p);case 3:insert(h_p);case 4:deleat(h_p);case 5:search(h_p);case 6:printall(h_p);case 7:save(head);case 8:password_set();if(b!=9)n保存吗?(y/n):%cif(a=y)return(b);void auto1(struct shop *h_p)if(password_exi(h_p) &
6、data_exi(h_p)load(h_p);void print1(void)*n 仓库管理系统 n n #* 菜单 *# n #| 1.员工模式 |# n #| 2.店主模式 |# n #| 3.退出 |# n #*# nn请选择(1-3):void assistant(struct shop *head)char a50,c=;struct shop *i;i=head;while(c=n请输入卖出的商品名称:ngets(a);n请输入卖出的商品数量:while(strcmp(i-name,a)!=0&i-next!=NULL)i=i-next;if(i-num_now-=b;win=(
7、i-num_in-i-num_now)*(i-price_out-i-price_in);elsen此商品不存在或通知店主更新数据库nn继续吗?c=getchar();int password(void)FILE*fp;char a50,b50;int i;fp=fopen(c:y_secrea,rbfscanf(fp,%sfclose(fp);请输入密码:i=0;bi=getch();*i+;while(bi-1!=13&iname,0)=0)f=0;while(f)n+;if(n=1)head=j;f=1;n请输入下一种货物的数据.nni=addbuild(&free(i);j-next=
8、i;j=i;next=NULL;*h_p=head;void rewrite(struct shop *h_p)char a30;struct shop *i,*j,*head;n请输入要修改货物的名称:if(n=1&!search1(h_p,a)n不存在的货物名称!if(head=NULL) goto end;while(nsearch1(h_p,a);while(strcmp(a,i-name)! if(strcmp(a,i-name)=0) printf(n真的要修改吗?? putchar( if(getchar()= getchar(); j=addbuild(h_p); strcpy
9、(i-name,j-name);price_in=j-price_in;price_out=j-price_out;num_in=j-num_in;num_now=j-num_now;num_sold=j-num_sold;win=j-win;percent=j-percent; free(j);n修改完成_nn end:void insert(struct shop *h_p)struct shop *i,*j,*x,*head;x=addbuild(h_p);i=j=head;name,x-name) if(strcmp(i-name)=0) if(i=head) head=x; else
10、 j-next=x; x- i-n插入完成_nn.void deleat(struct shop *h_p)struct shop*i,*j,*head;char a30,b;n请输入你要删除的货物的名称:n真的要删除吗?b=getchar();if(b=name,a)=0) head=i- free(i);next=i- n-;n删除完成_.nn *h_p=head;end:void search(struct shop *h_p)int begin,end,mid,t;struct shop *i,*head;n请输入要查询货物的名称:while(strcmp(i-=0)&if(strcm
11、p(i-name,a)=0)n名称t进价t售价t进货数目 存货数目 销量 t赢利t利率nn=n%s%10.2f%10.2f%10d%10d%10d%9.2f%10.2f,i-name,i-price_in,i-price_out,i-num_innum_now,i-num_sold,i-win,i-percent);n此货物不存在!void printall(struct shop *h_p)int a,c;char b=while(b=print3();a!=2&sort1(h_p);sort2(h_p);sort3(h_p);for(c=1,i=*h_p;=NULL;next,c+)n名称
12、t进价t售价t进货数目 存货数目 销量 t赢利t利率t排名n%s%10.2f%10.2f%10d%10d%10d%9.2f%10.2f%8dpercent,c);if(c%8=0)按任意键继续。查看其他排列方式?void save(struct shop *head)FILE *fp;attrib c:y_data -hdel c:y_datawb+for(i=head;next)fprintf(fp,%s%7.2f,%.2f,%d,%d,%d,%.2f,%.2f,y_data +hn_已保存nvoid password_set()int i,f=0,t=0;char a20,b20;请输入新密码(319位):ai=getch();while(ai-1!ai-1=n请确认新密码:if(strcmp(a,b)=0&i2)t=1;y_secrea -h,a);fclose(fp
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1