超市管理系统源程序#includestdio.h#includestring.h#defineMAX20#defineN3#definePAGE2#definePRINT1printf(---------------------\n)#definePRINT2printf(商品号--商品名称--商品种类--销售价格--生产日期(年-月-日)--保质期\n)#definePRINT3printf(%4d%s%s%8d%15%-%2d-%2d%10d\n,goods[i].num,goods[i].name,goods[i].kind,goods[i].out_price,goods[i].pro_time.year,goods[i].pro_time.month,goods[i].pro_time.date,goods[i].save_day)intsum;/*记录商品数目*/structdate/*日期结构体类型*/{intyear;intmonth;intdate;}structgoods_type/*商品结构体类型*/{intsum;charname[10];charkind[10];intamount;intgoods_up;intgoods_down;intin_price;intout_price;intin_num;structdatein_time;structdatepro_time;charfactory[10];intsave_day;intprofit;}goods[MAX];/*存放MAX种商品记录的结构体数据*/save_message(jinsum)/*保存信息*/{FILE*fp;inti;if((fp=fopen(supermarket.txt,wb))==NULL){printf(读文件错误!\n);return;}for(i=0;isum;i++)if(fwrite(&goods[i],sizeof(structgoods_type),1,fp)!=1)printf(写文件错误!\n);fclose(fp):}inputmessage()/*输入模块*/{inti=0,s=MAX;clrscr();printf(\n\n录入商品信息(最多%d种)\n,s);printf(-------------------------\n);do{printf(\n第%d种商品,i+1);printf(\n商品号:);scanf(%d,&goods[i].num);if(goods[i].num==0)break;printf(\n商品名称:);scanf(%s,goods[i].name);printf(\n商品类别:);scanf(%s,goods[i].kind);printf(\n商品总量:);scanf(%s,&goods[i].amout);printf(\n商品上限:);scanf(%s,&goods[i].goods_up);printf(\n商品下限:);scanf(%s,&goods[i].goods_down);printf(\n进货价格:);scanf(%s,&goods[i].in_price);printf(\n销售价格:);scanf(%s,&goods[i].out_price);printf(\n进货数量:);scanf(%s,&goods[i].in_num);printf(\n进货日期(yyyy-mm-dd):);scanf(%d-%d-%d,&goods[i].in_time.year,&goods[i].in_time.month,&goods[i].in_time.date);printf(\n商品名称:);printf(\n生产日期(yyyy-mm-dd):);scanf(%d-%d-%d,&goods[i].pro_time.year,&goods[i].pro_time.month,&goods[i].pro_time.date);printf(\n生产厂家:);scanf(%s,goods[i].factory);printf(\n保质期:);scanf(%s,goods[i].save_day);i++;}while(iMAX);printf(\n--%d种商品信息输入完毕!--\n,i);sum=i;printf(\n按任意键返回主菜单!);bioskey(0);}intread_message()/*读取信息*/{FILE*fp;inti=0;if((fp=fopen(supermarket.txt,rb))==NULL){printf(\n\n*****暂时还没有任何库存信息,按任意键进入主菜单选择基本信息的录入!******\n);return;}while(feof(fp)!=1){fread(&goods[i],sizeof(structgoods_type),1,fp);if(goods[i].num==0)break;elsei++;}fclose(fp);return(i);}output_message()/*输出模块*/{inti=0,j=0,count,page=1;clrscr();printf(\n\n--商品信息表--第%d页\n\n,page);PRINT2;PRINT1;do{if(goods[i].num!=0){j++;if(j%PAGE!=0){PRINT3;PRINT1;}else{PRINT3;PRINT1;if(goods[i+1].num!=0){printf(按任意键继续!);bioskey(0);clrscr();printf(\n\n--商品信息表--第%d页\n\n,++page);PRINT2;PRINT1;}}}i++;}while(goods[i].num!=0);printf(按任意键返回主菜单!);bioskey(0);}insert_message()/*添加商品信息*/{inti=sum,j,flag=0;charchoice;clrscr();printf(\n\n添加一种新商品\n);printf(--------------------\n);do{goods[i].num=++sum;printf(\n新商品号:%d,goods[i].num);printf(\n商品名称:);scanf(%s,goods[i].name);printf(\n商品类别:);scanf(%s,goods[i].kind);printf(\n商品总量:);scanf(%s,&goods[i].amout);printf(\n商品上限:);scanf(%s,&goods[i].goods_up);printf(\n商品下限:);scanf(%s,&goods[i].goods_down);printf(\n进货价格:);scanf(%s,&goods[i].in_price);printf(\n销售价格:);scanf(%s,&goods[i].out_price);printf(\n进货数量:);scanf(%s,&goods[i].in_num);printf(\n进货日期(yyyy-mm-dd):);scanf(%d-%d-%d,&goods[i].in_time.year,&goods[i].in_time.month,&goods[i].in_time.date);printf(\n商品名称:);printf(\n生产日期(yyyy-mm-dd):);scanf(%d-%d-%d,&goods[i].pro_time.year,&goods[i].pro_time.month,&goods[i].pro_time.date);printf(\n生产厂家:);scanf(%s,goods[i].factory);printf(\n保质期:);scanf(%s,goods[i].save_day);printf(\n要继续吗?(Y/N));choice=getch();if(choice=='y'||choice=='Y'){printf(\n继续!\n);i++;flag=1;}elseflag=0;}while(flag==1);printf(\n按任意键返回主菜单!);bioskey(0);}del_message()/*删除商品信息*/{;}revise_message()/*修改模块*/{inti=0,choice,revise_num,flag;do{clrscr();printf(\n输入要修改的商品号:);scanf(%d,&revise_num);for(i=0;isum;i++)if(goods[i].num==revise_num){printf(\n--商品信息--\n);PRINT1;PRINT2;PRINT3;printf(\n您要修改那一项?\n);printf(\n1.名称\n);printf(\n2.种类\n);printf(\n3.销售价格\n);printf(\n4.生产日期\n);printf(\n5.保质期\n);printf(\n请选择(1-5)\n);scanf(%d,&choice);switch(choice){case1;printf(\n输入修改后的名称:);scanf(%s,&goods[i].name);break;case2;printf(\n输入修改后的种类:);scanf(%s,&goods[i].kind);break;case3;printf(\n输入修改后的销售价格:);scanf(%s,&goods[i].out_price);break;case4;printf(\n输入修改后的生产日期:);scanf(%d-%d-%d,&goods[i].pro_time.year,&goods[i].pro_time.month,&goods[i].pro_time.date);break;case5;printf(\n输入修改后的保质期:);scanf(%s,&goods[i].save_day);break;}PRINT1;PRINT2;PRINT3;break;}if(i==sum){printf(\n该商品不存在!);bioskey(0);}printf(\n\n继续修改吗?(Y/N));choice=getch();if(choice=='y'||choice=='Y'){flag=1;printf(\n继续!\n);}elseflag=0;}while(flag==1);printf(\n按任意键返回主菜单!);bioskey(0);}renew_message()/*更新模块*/{intchoice;do{clrscr();printf(\n\n\n********更新商品信息*******\n\n);printf(1.添加商品信息\n\n);printf(2.删除商品信息\n\n);printf(3.修改商品信息\n\n);printf(0.返回主菜单\n\n);printf(请选择(0-3):\n\n);scanf(%d,&choice);switch(choice){case1:insert_message();break;case2:del_message();break;case3:revise_message();break;case0:break;}}while(choice!=0);}inquire_name(){inti,choixe,j=0,inquire_in_price;charinquire_name[10];clrscr();printf(\n输入要查询的商品名称:);scanf(%s,inquire_name);for(i=0;isum;i++)if(strcmp(goods[i].name,inquire_name)==0&&goods[i].num!=