资源描述:
《C语言商店销售管理系统课程设计.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、商店销售管理系统#include#include#defineN1000//N代表货物的最大种类structgoods{charname[10];//商品名称intamount;//商品数量intnum;//商品编号floatprice;//商品价格}sp[N],sc[N];//定义全局变量intflag=1;FILE*fp;inti=0;intk=0;intb=0;chakan()//显示目前的库存{intzong=0;fp=fopen("chaoshi.txt","r");for(i=1;i<=(k+b);i++)frea
2、d(&sp[i],sizeof(structgoods),1,fp);fclose(fp);for(i=1;i<=k;i++){zong=zong+sp[i].num;}if(zong!=0){printf("目前库存情况为:名称数量价格编号");for(i=1;i<=(k+b);i++){printf("%s%d%f%d",sp[i].name,sp[i].amount,sp[i].price,sp[i].num);}}elseprintf("#####目前库存为#####");}jinhuo()//进货模块{do{k++;i++;print
3、f("请输入商品的名称.数量.价格.标号(>0)例如:a12.5111ttt");scanf("%s%d%f%d%c",sp[i].name,&sp[i].amount,&sp[i].price,&sp[i].num);printf("是否继续,是(1),否(0)ttt");scanf("%d",&flag);}while(flag!=0);fp=fopen("chaoshi.txt","w");for(i=1;i<=k;i++)fwrite(&sp[i],sizeof(structgoods),1,fp);fclose(fp);chaka
4、n();}xiaoshou()//销售模块{floatm[100];intz=1;intj[100];inta[100];intg=0;inty=0;inth=0;floatzong=0;fp=fopen("chaoshi.txt","r");for(i=1;i<=k;i++)fread(&sp[i],sizeof(structgoods),1,fp);fclose(fp);do{g++;y++;loop:printf("请输入商品编号和数量,例如:(10020)ttt");scanf("%d%d",&j[y],&a[y]);for(z=1;z<=k
5、;z++){if(j[y]==sp[z].num){h++;sp[z].amount=sp[z].amount-a[y];m[y]=(float)a[y]*sp[z].price;sc[y]=sp[z];}}if(h==0){printf("输入有误,请重新输入ttt");gotoloop;}fp=fopen("chaoshi.txt","wt");for(i=1;i<=k;i++)fwrite(&sp[i],sizeof(structgoods),1,fp);fclose(fp);printf("是否继续,是(1),否(0)ttt");s
6、canf("%d",&flag);}while(flag!=0);printf("############################################");printf("编号名称单价数量总计");for(y=1;y<=g;y++){printf("%4d%10s%8.2f%6d%13.2f",sc[y].num,sc[y].name,sc[y].price,a[y],m[y]);zong=zong+m[y];}printf("您此次一共消费%f元,欢迎您下次光临",zong);shijian();}zengjia()/
7、/增加商品数量模块{floatm;intz=1;intj[100],a[100];intg=0;inty=0;intzong=0;inth=0;fp=fopen("chaoshi.txt","r");for(i=1;i<=k;i++)fread(&sp[i],sizeof(structgoods),1,fp);fclose(fp);do{g++;y++;loop:printf("请输入商品编号和数量,例如:(10020)ttt");scanf("%d%d",&j[y],&a[y]);for(z=1;z<=k;z++){if(j[y]==sp[z].n
8、um){h++;sp[z].amoun