超市管理系統(tǒng)程序_第1頁
超市管理系統(tǒng)程序_第2頁
超市管理系統(tǒng)程序_第3頁
超市管理系統(tǒng)程序_第4頁
超市管理系統(tǒng)程序_第5頁
已閱讀5頁,還剩9頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、 /* 超市管理系統(tǒng)程序*/*董能相*/#include<stdio.h>#include<string.h>#define MAX 20#define N 3#define PAGE 2#define PRINT1 printf("-n");#define PRINT2 printf("商品號(hào)-商品名稱-商品種類-銷售價(jià)格-生產(chǎn)日期(年-月-日)-保質(zhì)期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;/*用來記錄商品數(shù)目*/*日期結(jié)構(gòu)體類型*/struct date int year; int month; int date; ;/*商品結(jié)構(gòu)體類型*/struct goods_type int num; /* 商品數(shù)量*/ char name10; /*商品名稱*/ char kind10; /*商品種類*/ int amount; /*商品總量*/ int left_amount;/*商品剩余數(shù)量*/

3、int total_price; /*商品總價(jià)格*/ int goods_up; /*商品上限*/ int goods_down; /* 商品下限 */ int in_price; /*進(jìn)貨價(jià)格*/ int out_price; /*銷售價(jià)格*/ int in_num; /*進(jìn)貨數(shù)量*/ int out_num; /*售出數(shù)量*/ struct date in_time;/* 進(jìn)貨日期*/ struct date pro_time; /*生產(chǎn)日期*/ char factory10; /*生產(chǎn)廠家*/ int save_day; /*保質(zhì)期 */ int profit; /* 獲得利潤(rùn)*/goo

4、dsMAX;/*存放MAX種商品記錄的結(jié)構(gòu)體數(shù)組*/*保存信息*/save_message(int sum) FILE*fp; int i; if(fp=fopen("supermarket.txt","wb")=NULL) printf("讀文件錯(cuò)誤!n"); return; for(i=0;i<sum;i+) if(fwrite(&goodsi,sizeof(struct goods_type),1,fp)!=1) printf("寫文件錯(cuò)誤!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*暫時(shí)還沒有任何庫存信息,按任意鍵進(jìn)入主菜單選擇基本信息的錄入!*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("按任意鍵繼續(xù)!");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("要繼續(xù)嗎?(Y/N)"); choice=getch(); if(choice='Y'|choice=

16、9;y') printf("n 繼續(xù)!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、要繼續(xù)嗎? (Y/N)"); choice=getch(); if(choice='Y'|choice='y'); printf("n 繼續(xù)!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 您要修改哪一項(xiàng)?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 要繼續(xù)嗎?(Y/N)"); choice=getch(); if(choice='Y'|choice='y') flag=1; printf("n 繼續(xù)!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); /*按進(jìn)貨時(shí)間查詢*/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); /*按進(jìn)貨量查詢*/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);/*統(tǒng)計(jì)利潤(rùn)*/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);/*統(tǒng)計(jì)進(jìn)貨量*/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);/*統(tǒng)計(jì)庫存量*/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);/*統(tǒng)計(jì)模塊*/count_message() int choice;do clrscr(); printf("nnn*統(tǒng)計(jì)商品信息*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 排名 商品號(hào) 商品名稱 商品類別 庫存量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);/*利潤(rùn)排行*/sort_profit() struct goods_type *p,*qMAX; int i,j,k; clrscr(); printf("n 利潤(rùn)排行 n"); printf("-n"); printf("n 排名 商品號(hào) 商品名稱 商品類別 利潤(rù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 排名 商品號(hào) 商品名稱 商品類別 銷售量 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等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論