超市管理系统程序_第1页
超市管理系统程序_第2页
超市管理系统程序_第3页
超市管理系统程序_第4页
超市管理系统程序_第5页
已阅读5页,还剩9页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、 /* 超市管理系统程序*/*董能相*/#include<stdio.h>#include<string.h>#define MAX 20#define N 3#define PAGE 2#define PRINT1 printf("-n");#define PRINT2 printf("商品号-商品名称-商品种类-销售价格-生产日期(年-月-日)-保质期n");#define PRINT3 printf("%4d%8s%8s%8d%15d%15d%15-2%d-2%d%10dn",goodsi.num,goo

2、,goodsi.kind,goodsi.in_price,goodsi.out_price,_time,goodsi.save_day)int sum;/*用来记录商品数目*/*日期结构体类型*/struct date int year; int month; int date; ;/*商品结构体类型*/struct goods_type int num; /* 商品数量*/ char name10; /*商品名称*/ char kind10; /*商品种类*/ int amount; /*商品总量*/ int left_amount;/*商品剩余数量*/

3、int total_price; /*商品总价格*/ int goods_up; /*商品上限*/ int goods_down; /* 商品下限 */ int in_price; /*进货价格*/ int out_price; /*销售价格*/ int in_num; /*进货数量*/ int out_num; /*售出数量*/ struct date in_time;/* 进货日期*/ struct date pro_time; /*生产日期*/ char factory10; /*生产厂家*/ int save_day; /*保质期 */ int profit; /* 获得利润*/goo

4、dsMAX;/*存放MAX种商品记录的结构体数组*/*保存信息*/save_message(int sum) FILE*fp; int i; if(fp=fopen("supermarket.txt","wb")=NULL) printf("读文件错误!n"); return; for(i=0;i<sum;i+) if(fwrite(&goodsi,sizeof(struct goods_type),1,fp)!=1) printf("写文件错误!n"); fclose(fp);/*输入模块*/inp

5、ut_message() int i=0,s=MAX; clrscr(); printf("nn录入商品信息(最多%d种)n",s); printf("-n");do printf("n good%d",i+1); printf("n num:"); scanf("%d",&goodsi.num); printf("n name:"); scanf("%s",&); printf("n kind:"

6、); scanf("%s",&goodsi.kind); printf("n amount:"); scanf("%d",&goodsi.amount); printf("n goods_up:"); scanf("%d",&goodsi.goods_up); printf("n goods_down:"); scanf("%d",&goodsi.goods_down); printf("n in_price:&q

7、uot;); scanf("%d",&goodsi.in_price); printf("n out_price:"); scanf("%d",&goodsi.out_price); printf("n in_num:"); scanf("%d",&goodsi.in_num); printf("n in_date(yyyy-mm-dd):"); scanf("%d-%d-%d",&goodsi.in_time.year,&

8、amp;goodsi.in_time.month,&goodsi.in_time.date); printf("n pro_date(yyyy-mm-dd):"); scanf("%d-%d-%d",&_time.year,&_time.month,&_time.date); printf("n factory:"); scanf("%s",&goodsi.factory); printf("n save_

9、day:"); scanf("%d",&goodsi.save_day); i+;while(i<MAX); printf("n-%d种商品信息输入完毕!-n",i); sum=i; printf("n press any key return menu!"); bioskey(0);/*读取信息*/int read_message() FILE *fp; int i=0; if(fp=fopen("supermarket.txt","rb")=NULL) printf(

10、"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);/*输出模块*/void output_message() int i=0,j=0,count,page=1; clrscr(); printf("nn-%dnn",page); PRINT2; PRINT1;do

11、 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("press any key return menu!"); bioskey(0);/*添加商品信息*/in

12、sert_message() int i=sum,j,flag=0; char choice; clrscr(); printf("nn 添加一种新商品n"); printf("-n");do goodsi.num=+sum; printf("new num:%d",goodsi.num); printf("n name:"); scanf("%s",); printf("n kind:"); scanf("%s",goodsi.ki

13、nd); printf("n amount:"); scanf("%d",goodsi.amount); printf("n goods_up:"); scanf("%d",goodsi.goods_up); printf("n goods_down:"); scanf("%d",goodsi.goods_down); printf("n in_price:"); scanf("%d",goodsi.in_price); printf(

14、"n out_price:"); scanf("%d",goodsi.out_price); printf("n in_num:"); scanf("%d",goodsi.num); printf("n in_time:"); scanf("%d%d%d",goodsi.in_time.year,goodsi.in_time.month,goodsi.in_time.date); printf("n pro_time:"); scanf("%d%

15、d%d",_time.year, _time.month, _time.date); printf("n factory:"); scanf("%s",goodsi.factory); printf("n save_day:"); scanf("%d",goodsi.save_day); printf("要继续吗?(Y/N)"); choice=getch(); if(choice='Y'|choice=

16、9;y') printf("n 继续!n"); i+; flag=1; else flag=0;while(flag=1); printf("n press any key return menu!"); bioskey(0);/*删除商品信息*/del_message() int i=sum,j,flag=0; char choice; clrscr(); printf("nnn"); printf("-n");do goodsi.num=-sum; printf("n num:");

17、 printf("n name:"); scanf("%s",); printf("n kind:"); scanf("%s",goodsi.kind); printf("n left_amount:"); scanf("%d",goodsi.left_amount); printf("n total_price:"); scanf("%d",goodsi.total_price); printf("n

18、要继续吗? (Y/N)"); choice=getch(); if(choice='Y'|choice='y'); printf("n 继续!n"); i+; flag=1;while(flag=1); printf("n press any key enter the menu!"); bioskey(0);/*修改模块*/revise_message() int i=0,choice,revise_num,flag; do clrscr(); printf("n input the number o

19、f the good :"); scanf("%d",&revise_num); for(i=0;i<sum;i+) if(goodsi.num=revise_num) printf("n-n"); PRINT1; PRINT2; PRINT3; printf("n 您要修改哪一项?n"); printf("n 1.namen"); printf("n 2.kindn"); printf("n 3.out_pricen"); printf("

20、n 4.pro_timen"); printf("n 5.save_dayn"); printf("n please make your choice(1-5):"); scanf("%d",&choice);switch(choice) case 1:printf("n name:"); scanf("%s",&);break; case 2:printf("n kind:"); scanf("%s",&a

21、mp;goodsi.kind);break; case 3:printf("n out_price:"); scanf("%d",&goodsi.out_price);break; case 4:printf("n pro_time:"); scanf("%d%d%d",&_time.year,&_time.month, &_time.date);break; case 5:printf("n save_day:&

22、quot;); scanf("%d",&goodsi.save_day);break; PRINT1; PRINT2; PRINT3;break;if(i=sum) printf("n该商品不存在!"); bioskey(0); printf("nn 要继续吗?(Y/N)"); choice=getch(); if(choice='Y'|choice='y') flag=1; printf("n 继续!n"); else flag=0;while(flag=1); print

23、f("n press any key return menu!"); bioskey(0);/*更新模块*/renew_message() int choice;do clrscr(); printf("nnn*更新商品信息*nn"); printf(" 1.insert_messagenn"); printf(" 2.del_messagenn"); printf(" 3.revise_messagenn"); printf(" 0.return menunn"); pri

24、ntf(" please make your choice(0-3):"); scanf("%d",&choice);switch(choice) case 1:insert_message();break; case 2:del_message();break; case 3:revise_message();break; case 0:break;while(choice!=0);/*按名称查询*/inquire_name() int i,choice,j=0,inquire_in_price; char inquire_name10; cl

25、rscr(); printf("n input the name of the good:"); scanf("%s",inquire_name); for(i=0;i<sum;i+) if(strcmp(,inquire_name)=0&&goodsi.num!=0) printf("n -商品信息-n"); PRINT1; PRINT2; PRINT3; else j+; if(j=sum) printf("n 该商品不存在!"); bioskey(0);/*按类别查

26、询*/inquire_kind() int i=0,choice,j=0,inquire_in_price; char inquire_kind10; clrscr(); printf("n input the kind of the good:"); scanf("%s",inquire_kind); if(strcmp(goodsi.kind,inquire_kind)=0&&goodsi.num=!0); printf("n -商品信息-n"); PRINT1; PRINT2; PRINT3; if(j=sum)

27、 printf("n 该商品不存在!"); bioskey(0); /*按进货时间查询*/inquire_in_time() int i,choice,j=0,inquire_in_price; struct date in_time; clrscr(); printf("n input the in time of the good:"); scanf("%d",inquire_in_time); for(i=0;i<sum;i+) if(goodsi.num!=0) printf("n-商品信息-n");

28、 PRINT1; PRINT2; PRINT3; else j+; if(j=sum) printf("该商品不存在!n"); bioskey(0); /*按进货量查询*/inquire_in_num() int i,choice,j=0,inquire_in_price; int inquire_in_num; clrscr(); printf("n input the in number of the good:"); scanf("%d",inquire_in_time); for(i=0;i<sum;i+) if(goo

29、dsi.num!=0) printf("n-商品信息-n"); PRINT1; PRINT2; PRINT3; else j+; if(j=sum) printf("该商品不存在!n"); bioskey(0);/*查询模块*/inquire_message() int choice;do clrscr(); printf("nnn*查询商品信息*nn"); printf(" 1.inquire_namenn"); printf(" 2.inquire_kindnn"); printf(&quo

30、t; 3.inquire_in_timenn"); printf(" 4.inquire_in_numnn"); printf(" 0.return menunn"); printf("please make your choice (0-4):"); scanf("%d",&choice);switch(choice) case 1:inquire_name();break; case 2:inquire_kind();break; case 3:inquire_in_time();break;

31、 case 4:inquire_in_num();break; case 0:break; while(choice!=0);/*统计利润*/count_profit() int i,choice,j=0,count_num,profit; char inquire_name10; clrscr(); printf("n input the number of the good :"); scanf("%d",&count_num); for(i=0;i<sum;i+) if(goodsi.num=count_num) profit=goo

32、dsi.out_price-goodsi.in_price; printf("n profit:"); printf("n-n"); printf("n num profit"); printf("n%25d%13dn",goodsi.num,profit); else j+; if(j=sum) printf("n 该商品不存在!"); bioskey(0);/*统计进货量*/count_in_num() int i,choice,j=0,count_num,in_num; char inqu

33、ire_name10; clrscr(); printf("n input the amount of the good:"); scanf("%d",&count_in_num); for(i=0;i<sum;i+) if(goodsi.in_num!=0) printf("n %dn",in_num); else j+; if(j=sum) printf("n 该商品不存在!"); bioskey(0);/*统计库存量*/count_full() int i,choic,j=0,count_num

34、,full; int in_num; int out_num; char inquire_name10; clrscr(); printf("n input the number of the good:"); scanf("%d",&count_full); for(i=0;i<sum;i+) if(goodsi.num!=0) full=goodsi.in_num-goodsi.out_num; printf("n full:"); printf("n-n"); printf("n nu

35、m full"); printf("n%25d%13dn",goodsi.num,full); else j+; if(j=sum) printf("n 该商品不存在!"); bioskey(0);/*统计模块*/count_message() int choice;do clrscr(); printf("nnn*统计商品信息*nn"); printf(" 1.count_profitnn"); printf(" 2.count_in_numnn"); printf(" 3

36、.count_fullnn"); printf(" 0.return menunn"); printf("please make your choice (0-3):"); scanf("%d",&choice);switch(choice) case 1:count_profit();break; case 2:count_in_num();break; case 3:count_full();break; case 0:break; while(choice!=0);/*库存排行*/sort_amount() s

37、truct goods_type *p,*qMAX; int i,j,k; clrscr(); printf("n 库存排行 n"); printf("-n"); printf("n 排名 商品号 商品名称 商品类别 库存量n"); p=goods; for(i=0;i<sum;i+) qi=p+; for(i=0;i<sum;i+) k=i; for(j=i+1;j<sum;j+) if(qk->amount<qi->amount) k=j; if(k!=i) qi=qi;qi=qk;qk=p;

38、for(i=0;i<sum;i+) printf("n%18d %6d %8s %11dn",i+1,qi->name,qi->kind,qi->amount); bioskey(0);/*利润排行*/sort_profit() struct goods_type *p,*qMAX; int i,j,k; clrscr(); printf("n 利润排行 n"); printf("-n"); printf("n 排名 商品号 商品名称 商品类别 利润 n"); p=goods; for(i=

39、0;i<sum;i+) qi=p+; for(i=0;i<sum;i+) k=i; for(j=i+1;j<sum;j+) if(qk->profit<qi->profit) k=j; if(k!=i) qi=qi;qi=qk;qk=p; for(i=0;i<sum;i+) printf("n%18d %6d %8s %11dn",i+1,qi->name,qi->kind,qi->profit); bioskey(0);/*销售量排行*/sort_out_num() struct goods_type *p,*qMAX; int i,j,k; clrscr(); printf("n 销售量排行 n"); printf("-n"); printf("n 排名 商品号 商品名称 商品类别 销售量 n"); p=goods; for(i=0;i<sum;i+) qi=p+; for(i=0;i<sum;i+) k=i; for(j=i+1;j<sum;j+) if(qk->out_num<qi->out_num) k=j; if(

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论