资源预览内容
第1页 / 共24页
第2页 / 共24页
第3页 / 共24页
第4页 / 共24页
第5页 / 共24页
第6页 / 共24页
第7页 / 共24页
第8页 / 共24页
第9页 / 共24页
第10页 / 共24页
亲,该文档总共24页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
超市管理系统源程序12020年5月29日文档仅供参考 超市管理系统源程序#include #include #define MAX 20#define N 3#define PAGE 2#define PRINT1 printf(-n)#define PRINT2 printf(商品号-商品名称-商品种类-销售价格-生产日期(年-月-日)-保质期n)#define PRINT3 printf(%4d%s%s%8d%15%-%2d-%2d%10dn,goodsi.num,goodsi.name,goodsi.kind,goodsi.out_price,goodsi.pro_time.year,goodsi.pro_time.month,goodsi.pro_time.date,goodsi.save_day)int sum;/*记录商品数目*/struct date /*日期结构体类型*/ int year; int month; int date;struct goods_type /*商品结构体类型*/ int sum; char name10; char kind10; int amount; int goods_up; int goods_down; int in_price; int out_price; int in_num; struct date in_time; struct date pro_time; char factory10; int save_day; int profit;goodsMAX; /*存放MAX种商品记录的结构体数据*/save_message(jin sum) /*保存信息*/ FILE *fp; int i; if(fp=fopen(supermarket.txt,wb)=NULL) printf(读文件错误!n); return; for(i=0;isum;i+) if(fwrite(&goodsi,sizeof(struct goods_type),1,fp)!=1) printf(写文件错误!n); fclose(fp):input message() /*输入模块*/ int i=0,s=MAX; clrscr(); printf(nn 录入商品信息 (最多%d种)n,s); printf( -n); do printf(n 第%d种商品,i+1); printf(n 商品号:); scanf(%d,&goodsi.num); if(goodsi.num=0) break; printf(n 商品名称:); scanf(%s,goodsi.name); printf(n 商品类别:); scanf(%s,goodsi.kind); printf(n 商品总量:); scanf(%s,&goodsi.amout); printf(n 商品上限:); scanf(%s,&goodsi.goods_up); printf(n 商品下限:); scanf(%s,&goodsi.goods_down); printf(n 进货价格:); scanf(%s,&goodsi.in_price); printf(n 销售价格:); scanf(%s,&goodsi.out_price); printf(n 进货数量:); scanf(%s,&goodsi.in_num); printf(n 进货日期(yyyy-mm-dd):); scanf(%d-%d-%d,&goodsi.in_time.year,&goodsi.in_time.month,&goodsi.in_time.date); printf(n 商品名称:); printf(n 生产日期(yyyy-mm-dd):); scanf(%d-%d-%d,&goodsi.pro_time.year,&goodsi.pro_time.month,&goodsi.pro_time.date); printf(n 生产厂家:); scanf(%s,goodsi.factory); printf(n 保质期:); scanf(%s,goodsi.save_day); i+; while(iMAX); printf(n -%d种商品信息输入完毕!-n,i); sum=i; printf(n 按任意键返回主菜单!); bioskey(0);int read_message() /*读取信息*/ FILE *fp; int i=0; if(fp=fopen(supermarket.txt,rb)=NULL) printf(nn*暂时还没有任何库存信息,按任意键进入主菜单选择基本信息的录入!*n); return; while(feof(fp)!=1) fread(&goodsi,sizeof(struct goods_type),1,fp); if(goodsi.num=0) break; else i+; fclose(fp); return(i);output_message() /*输出模块*/ int i=0,j=0,count,page=1; clrscr(); printf(nn -商品信息表- 第%d页nn,page); PRINT2; PRINT1; do if(goodsi.num!=0) j+; if(j%PAGE!=0) PRINT3; PRINT1; else PRINT3; PRINT1; if(goodsi+1.num!=0) printf(按任意键继续!); bioskey(0); clrscr(); printf(nn -商品信息表- 第%d页nn,+page); PRINT2; PRINT1; i+; while(goodsi.num!=0); printf(按任意键返回主菜单!); bioskey(0);insert_message() /*添加商品信息*/ int i=sum,j,flag=0; char choice; clrscr(); printf(nn 添加一种新商品n); printf( -n); do goodsi.num=+sum; printf(n 新商品号:%d,goodsi.num); printf(n 商品名称:); scanf(%s,goodsi.name); printf(n 商品类别:); scanf(%s,goodsi.kind); printf(n 商品总量:); scanf(%s,&goodsi.amout); printf(n 商品上限:); scanf(%s,&goodsi.goods_up); printf(n 商品下限:); scanf(%s,&goodsi.goods_down); printf(n 进货价格:); scanf(%s,&goodsi.in_price); printf(n 销售价格:); scanf(%s,&goodsi.out_price); printf(n 进货数量:); scanf(%s,&goodsi.in_num); printf(n 进货日期(yyyy-mm-dd):); scanf(%d-%d-%d,&goodsi.in_time.year,&goodsi.in_time.month,&goodsi.in_time.date); printf(n 商品名称:); printf(n 生产日期(yyyy-mm-dd):); scanf(%d-%d-%d,&goodsi.pro_time.year,&goodsi.pro_time.month,&goodsi.pro_time.date); printf(n 生产厂家:); scanf(%s,goods
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号