超市管理系統(tǒng) C語(yǔ)言_第1頁(yè)
超市管理系統(tǒng) C語(yǔ)言_第2頁(yè)
超市管理系統(tǒng) C語(yǔ)言_第3頁(yè)
超市管理系統(tǒng) C語(yǔ)言_第4頁(yè)
超市管理系統(tǒng) C語(yǔ)言_第5頁(yè)
已閱讀5頁(yè),還剩30頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡(jiǎn)介

1、西安郵電大學(xué)高級(jí)語(yǔ)言課程設(shè)計(jì)報(bào)告題 目: 超市管理系統(tǒng)院系名稱(chēng): 理學(xué)院 專(zhuān)業(yè)名稱(chēng): 應(yīng)用物理學(xué)班 級(jí): 1301 學(xué)生姓名: 王松學(xué)號(hào)(8位): 指導(dǎo)教師: 王西龍?jiān)O(shè)計(jì)起止時(shí)間:2014年06月19日2014年06月27日1:程序模型2:原函數(shù)概況1:創(chuàng)建函數(shù)void start(); /*啟動(dòng)界面*/void input(); /*商品數(shù)據(jù)信息輸入函數(shù)*/void change(); /*商品數(shù)據(jù)信息修改函數(shù)*/void dele(); /*給定指定商品名稱(chēng),刪除商品信息*/void output(); /*商品信息輸出*/void search(); /*商品信息查找*/void mim

2、a();/*密碼程序*/void colour();/顏色選擇void huanying();2:商品信息錄入input()3:商品信息的修改Change()4:商品信息的刪除Dele()5:商品信息的查詢(xún)Seaerch()6:系統(tǒng)顏色選擇Colour()7:退出系統(tǒng)3:詳細(xì)設(shè)計(jì)過(guò)程1:結(jié)構(gòu)體變量的定義struct MarketGoods /*存數(shù)商品信息的結(jié)構(gòu)體*/ char goods_id30; /*商品編號(hào)*/ char goods_name30; /*商品名稱(chēng)*/double goods_price; /*商品價(jià)格*/double goods_discount;/*商品折扣*/int

3、 goods_amount;/*商品總數(shù)目*/int goods_remain;/*商品剩余數(shù)目*/goodsCOUNT;int count=0; /*全局變量,用于保存實(shí)際上有多少個(gè)商品*/2:歡迎界面void huanying()printf(t333333333333333333333333333333n); printf(t3 歡迎使用 3n); printf(t3 3n); printf(t3 3n); printf(t3 超市管理系統(tǒng) 3n); printf(t3 3n); printf(t3 3n); printf(t3 444444 3n); printf(t3 3n); pr

4、intf(t3 555555555 3n); printf(t3 3n);printf(t3333333333333333333333333333333n);3:密碼登陸void mima()/char pass6=1,2,3,4,5,6;/*假設(shè)密碼長(zhǎng)度是6*/ char pass=;/*假設(shè)密碼長(zhǎng)度是6*/ char str6,ch;int i=0;int flag=0;printf( 請(qǐng)輸入密碼:); fflush(stdin);for(i=0;i6;i+) ch=getch(); /*讀取字符,不顯示*/stri=ch;putchar(*); for(i=0;i6;i+)if(stri

5、!=passi) flag=1;break;if(flag)printf(n密碼錯(cuò)誤,登錄失敗!請(qǐng)重新登錄n);mima();else printf(n登錄成功n);getch();system(cls);start();4:系統(tǒng)選擇界面void start() /*啟動(dòng)菜單*/int chi; printf( 超市商品管理系統(tǒng)n);printf( *n); printf( *n); printf( 1.商品信息的錄入:n);printf( 2.商品信息的修改:n); printf( 3.刪除某個(gè)商品信息:n); printf( 4.查找商品信息:n); printf( 5.顏色選擇:n);

6、printf( 0.退出程序n);printf( *n); printf( *n); printf( 輸入你的選擇: ); scanf(%d,&chi); /*根據(jù)你的選擇執(zhí)行相應(yīng)的函數(shù)*/if(chi=1) input(); else if(chi=2) change();else if(chi=3) dele();else if(chi=4) search(); else if(chi=5) colour();else if(chi=0) printf(你已經(jīng)退出超市商品管理系統(tǒng)!謝謝您的使用,再見(jiàn)n); exit(0);elseprintf( You Enter The Choice I

7、s Not valid ! n);getch();system(cls);start();void huanying()printf(t333333333333333333333333333333n); printf(t3 歡迎使用 3n); printf(t3 3n); printf(t3 3n); printf(t3 超市管理系統(tǒng) 3n); printf(t3 3n); printf(t3 3n); printf(t3 444444 3n); printf(t3 3n); printf(t3 555555555 3n); printf(t3 3n);printf(t333333333333

8、3333333333333333333n);5:商品信息的錄入void input() /*數(shù)據(jù)錄入*/FILE *fp;char flag20;fp=fopen(e:/student.txt,wt);doprintf(請(qǐng)輸入你的商品信息:n); /*錄入商品的信息*/ printf(商品編號(hào):); scanf(%s,goodscount.goods_id); printf(商品名字:); scanf(%s,goodscount.goods_name); printf(商品價(jià)格:); scanf(%lf,&goodscount.goods_price); printf(商品折扣:); scan

9、f(%lf,&goodscount.goods_discount); printf(商品總數(shù)目:); scanf(%d,&goodscount.goods_amount); printf(商品剩余數(shù)目:); scanf(%d,&goodscount.goods_remain); count+; /*存數(shù)的商品數(shù)加一*/ printf(是否繼續(xù)輸入數(shù)據(jù) y是 n否 : ); /*是否還想繼續(xù)輸入數(shù)據(jù)*/ scanf(%s,flag); while(strcmp(flag,y)=0|strcmp(flag,Y)=0);fwrite(&goods,sizeof(struct MarketGoods)

10、,count,fp);fclose(fp);output(); /*調(diào)用顯示商品數(shù)據(jù)*/getch();system(cls);start();6:商品信息的修改void change() /*數(shù)據(jù)修改*/ FILE *fp;int i,m=0;char ch20,a20;fp=fopen(e:/student.txt,rt);while(fread(&goodsm,sizeof(struct MarketGoods),1,fp)!=NULL)m+;fclose(fp);printf(nyou sure want change goodsInfor y/n): );/*根據(jù)商品的id來(lái)修改數(shù)據(jù)

11、*/ scanf(%s,ch); if(strcmp(ch,y)=0|strcmp(ch,Y)=0) printf(nenter you want change goods_id:); scanf(%s,a); for(i=0;icount;i+) if(strcmp(goodsi.goods_id,a)=0) printf(nyou sure want change goods name(y/n): ); scanf(%s,ch); if(strcmp(ch,y)=0|strcmp(ch,Y)=0) printf(nname:);scanf(%s,goodsi.goods_name); pr

12、intf(nyou sure want change goods price(y/n): ); scanf(%s,ch); if(strcmp(ch,y)=0|strcmp(ch,Y)=0) printf(nprice);scanf(%lf,&goodsi.goods_price); printf(nyou sure want goods discount(y/n): ); scanf(%s,ch); if(strcmp(ch,y)=0|strcmp(ch,Y)=0) printf(ndiscount); scanf(%lf,&goodsi.goods_discount); printf(ny

13、ou sure want goods amount(y/n): ); scanf(%s,ch); if(strcmp(ch,y)=0|strcmp(ch,Y)=0) printf(namount);scanf(%d,&goodsi.goods_amount);printf(nyou sure want goods remain(y/n): ); scanf(%s,ch); if(strcmp(ch,y)=0|strcmp(ch,Y)=0) printf(nremain); scanf(%d,&goodsi.goods_remain); fwrite(&goods,sizeof(struct M

14、arketGoods),count,fp);fclose(fp);output();getch();system(cls);start();7:商品信息的刪除void dele() /*數(shù)據(jù)刪除*/FILE *fp;int i,m=0,j;char ch20,c20;fp=fopen(e:/student.txt,rt);while(fread(&goodsm,sizeof(struct MarketGoods),1,fp)!=NULL)printf(%s,goodsm.goods_id);m+;fclose(fp);printf(nenter you want delete name :n)

15、; /*根據(jù)商品的名稱(chēng)來(lái)刪除數(shù)據(jù)*/ printf(name:); scanf(%s,c); for(i=0;icount;i+) if(strcmp(c,goodsi.goods_name)=0) break; /*找到,即跳出循環(huán)*/ for(j=i;jcount-1;j+) goodsj=goodsj+1; printf(tttyou had delete %sn,c); count-;fp=fopen(e:/student.txt,wt);fwrite(&goods,sizeof(struct MarketGoods),count,fp);fclose(fp);output();get

16、ch();system(cls);start();8:商品信息查詢(xún)void search() /*數(shù)據(jù)查找*/FILE *fp;int i,m=0;char a20;fp=fopen(e:/student.txt,rt);while(fread(&goodsm,sizeof(struct MarketGoods),1,fp)!=NULL)printf(%s,goodsm.goods_name);m+;printf(nenter you want look name:); /*根據(jù)商品的名稱(chēng)來(lái)查找數(shù)據(jù)*/ scanf(%s,a); for(i=0;im;i+)if(strcmp(goodsi.g

17、oods_name,a)=0) printf(%s %s %lf %lf %d %d n,goodsi.goods_id,goodsi.goods_name,goodsi.goods_price,goodsi.goods_discount,goodsi.goods_amount,goodsi.goods_remain);getch();system(cls);start();9:系統(tǒng)顏色選擇void colour() int a; printf(nntt選擇以下方案n);printf(nntt1*紅底黑字n);printf(nntt2*白底黑子);printf(nntt3*黑底紅字);prin

18、tf(nntt4*綠底藍(lán)字);printf(nntt5*黃底藍(lán)字);printf(nntt6*系統(tǒng)默認(rèn));printf(nntttt請(qǐng)?zhí)暨x您喜歡的顏色.);scanf(%d,&a);switch(a)case 1:system(color 40); break;case 2:system(color 70); break;case 3:system(color 04); break;case 4:system(color 21); break;case 5:system(color 65); break;case 6:system(color la); break;default:printf

19、(nntttt輸入無(wú)效);getch();colour(); start();10:商品信息輸出void output() /*數(shù)據(jù)輸出*/ FILE *fp; int i,m=0;fp=fopen(e:/student.txt,rt);while(fread(&goodsm,sizeof(struct MarketGoods),1,fp)!=NULL)m+; fclose(fp);printf( 編號(hào) 名稱(chēng) 價(jià)格 折扣 總數(shù)目 剩余數(shù)目 n);for(i=0;im;i+)printf(%s %s %lf %lf %10d %10d n,goodsi.goods_id,goodsi.goods

20、_name,goodsi.goods_price,goodsi.goods_discount,goodsi.goods_amount,goodsi.goods_remain);getch();system(cls);start();11:退出系統(tǒng) void start() /*啟動(dòng)菜單*/int chi; printf( 超市商品管理系統(tǒng)n);printf( *n); printf( *n); printf( 1.商品信息的錄入:n);printf( 2.商品信息的修改:n); printf( 3.刪除某個(gè)商品信息:n); printf( 4.查找商品信息:n); printf( 5.顏色選擇

21、:n); printf( 0.退出程序n);printf( *n); printf( *n); printf( 輸入你的選擇: ); scanf(%d,&chi); /*根據(jù)你的選擇執(zhí)行相應(yīng)的函數(shù)*/if(chi=1) input(); else if(chi=2) change();else if(chi=3) dele();else if(chi=4) search(); else if(chi=5) colour();else if(chi=0) printf(你已經(jīng)退出超市商品管理系統(tǒng)!謝謝您的使用,再見(jiàn)n); exit(0);4:調(diào)試分析調(diào)試過(guò)程中,會(huì)有很多的錯(cuò)誤。語(yǔ)句和函數(shù)的運(yùn)用不

22、到位,還存在許多的小錯(cuò)誤。5:測(cè)試結(jié)果 通過(guò)我想同學(xué)求助,向老師咨詢(xún),查找書(shū)籍,在網(wǎng)絡(luò)上查找,最終使得程序順利運(yùn)行。1:歡迎界面2:密碼輸入3:系統(tǒng)菜單選擇界面4:商品信息錄入及保存5:商品信息的修改6:商品信息的刪除及剩余物品記錄7:物品信息的查詢(xún)8:商品信息輸出9:系統(tǒng)環(huán)境顏色的選擇10:退出系統(tǒng) 課程設(shè)計(jì)總結(jié)上學(xué)期學(xué)習(xí)了C語(yǔ)言,所以對(duì)于C語(yǔ)言有了初步和基礎(chǔ)的認(rèn)識(shí)。這次做程序設(shè)計(jì),許多的程序過(guò)程都是通過(guò)咨詢(xún)老師,同學(xué),查詢(xún)網(wǎng)絡(luò),查找書(shū)籍做的。感到自己的C語(yǔ)言知識(shí)還是很欠缺。程序中許多都是自己設(shè)計(jì)的簡(jiǎn)單的語(yǔ)句,很少有精彩的部分,但是很知足,畢竟是自己第一次做,感覺(jué)挺好。但是總結(jié)下來(lái),自己可是

23、漏洞百出。通過(guò)一周多的實(shí)習(xí)設(shè)計(jì),使我對(duì)于C語(yǔ)言有了更深刻,更多的了解,也是我認(rèn)識(shí)到C語(yǔ)言的難度,但是,我又感覺(jué)到了這門(mén)課程的樂(lè)趣,看著自己的成果一天天出現(xiàn),那種喜悅是不可言語(yǔ)的。過(guò)程中,我發(fā)現(xiàn)自己的基礎(chǔ)知識(shí)薄弱,英語(yǔ)很多不認(rèn)識(shí),知識(shí)做的過(guò)程中還要上查詢(xún)英語(yǔ)方面的知識(shí),很是費(fèi)事。還有就是有些概念很模糊,但是通過(guò)這次實(shí)習(xí),我對(duì)于C語(yǔ)言有了新的認(rèn)識(shí)。在這一周時(shí)間里,經(jīng)過(guò)不斷的與同學(xué)和老師的討論,是我的C語(yǔ)言水平有了很大的提高。此次我還感覺(jué)到,C語(yǔ)言是一門(mén)實(shí)用性很強(qiáng)的課程。其實(shí)真正的程序過(guò)程就是頭文件,主函數(shù),模塊函數(shù)。這些東西的組合才構(gòu)成了一個(gè)完整的函數(shù)體系。雖然說(shuō)只有這幾項(xiàng),但是就是這簡(jiǎn)單的幾項(xiàng),

24、在一起通過(guò)邏輯,順序,等關(guān)系羅列開(kāi)來(lái),構(gòu)成了復(fù)雜的函數(shù)體。我就是在程序作業(yè)工程中老是在各種邏輯順序中迷糊,所以浪費(fèi)了很長(zhǎng)時(shí)間。這次的實(shí)驗(yàn)設(shè)計(jì),讓我對(duì)C語(yǔ)言有了很大的興趣。我相信我還會(huì)去自學(xué)的,因?yàn)槲抑乐皇且婚T(mén)可以武裝子的課程。相信,通過(guò)這次的學(xué)習(xí),還有以后的學(xué)習(xí),會(huì)是我的C語(yǔ)言有很大的提高。 源程序#include #include #include #include #define COUNT 30 /*聲明商品的種類(lèi)為30中*/#define N 30void start(); /*啟動(dòng)界面*/void input(); /*商品數(shù)據(jù)信息輸入函數(shù)*/void change(); /*商品

25、數(shù)據(jù)信息修改函數(shù)*/void dele(); /*給定指定商品名稱(chēng),刪除商品信息*/void output(); /*商品信息輸出*/void search(); /*商品信息查找*/void mima();/*密碼程序*/void colour();/顏色選擇void huanying();void paixu();struct MarketGoods /*存數(shù)商品信息的結(jié)構(gòu)體*/ char goods_id30; /*商品編號(hào)*/ char goods_name30; /*商品名稱(chēng)*/double goods_price; /*商品價(jià)格*/double goods_discount;/*商

26、品折扣*/int goods_amount;/*商品總數(shù)目*/int goods_remain;/*商品剩余數(shù)目*/goodsCOUNT;int count=0; /*全局變量,用于保存實(shí)際上有多少個(gè)商品*/void main() /*主函數(shù)*/ huanying();mima();start(); void start() /*啟動(dòng)菜單*/int chi; printf( 超市商品管理系統(tǒng)n);printf( *n); printf( *n); printf( 1.商品信息錄入:n);printf( 2.商品信息修改:n); printf( 3.商品信息刪除:n); printf( 4.商品

27、信息查找:n); printf( 5.系統(tǒng)顏色選擇:n); printf( 6.商品信息輸出:n); printf( 0.退出程序n);printf( *n); printf( *n); printf( 輸入你的選擇: ); scanf(%d,&chi); /*根據(jù)你的選擇執(zhí)行相應(yīng)的函數(shù)*/if(chi=1) input(); else if(chi=2) change();else if(chi=3) dele();else if(chi=4) search(); else if(chi=5) colour(); else if(chi=6) output();else if(chi=0)

28、printf(你已經(jīng)退出超市商品管理系統(tǒng)!謝謝您的使用,再見(jiàn)n); exit(0);elseprintf( You Enter The Choice Is Not valid ! n);getch();system(cls);start();void huanying()printf(t333333333333333333333333333333n); printf(t3 歡迎使用 3n); printf(t3 3n); printf(t3 3n); printf(t3 超市管理系統(tǒng) 3n); printf(t3 3n); printf(t3 3n); printf(t3 444444 3n)

29、; printf(t3 3n); printf(t3 555555555 3n); printf(t3 3n);printf(t3333333333333333333333333333333n);void mima()/char pass6=1,2,3,4,5,6;/*假設(shè)密碼長(zhǎng)度是6*/ char pass=;/*假設(shè)密碼長(zhǎng)度是6*/ char str6,ch;int i=0;int flag=0;printf( 請(qǐng)輸入密碼:); fflush(stdin);for(i=0;i6;i+) ch=getch(); /*讀取字符,不顯示*/stri=ch;putchar(*); for(i=0;

30、i6;i+)if(stri!=passi) flag=1;break;if(flag)printf(n密碼錯(cuò)誤,登錄失敗!請(qǐng)重新登錄n);mima();else printf(n登錄成功n);getch();system(cls);start();void input() /*數(shù)據(jù)錄入*/FILE *fp;char flag20;fp=fopen(e:/student.txt,wt);doprintf(請(qǐng)輸入你的商品信息:n); /*錄入商品的信息*/ printf(商品編號(hào):); scanf(%s,goodscount.goods_id); printf(商品名字:); scanf(%s,g

31、oodscount.goods_name); printf(商品價(jià)格:); scanf(%lf,&goodscount.goods_price); printf(商品折扣:); scanf(%lf,&goodscount.goods_discount); printf(商品總數(shù)目:); scanf(%d,&goodscount.goods_amount); printf(商品剩余數(shù)目:); scanf(%d,&goodscount.goods_remain); count+; /*存數(shù)的商品數(shù)加一*/ printf(是否繼續(xù)輸入數(shù)據(jù) y是 n否 : ); /*是否還想繼續(xù)輸入數(shù)據(jù)*/ scan

32、f(%s,flag); while(strcmp(flag,y)=0|strcmp(flag,Y)=0);fwrite(&goods,sizeof(struct MarketGoods),count,fp);fclose(fp);output(); /*調(diào)用顯示商品數(shù)據(jù)*/getch();system(cls);start();void paixu()FILE *fp; int m=0;int u,j,t;double dN+1;fp=fopen(e:/student.txt,rt);while(fread(&goodsm,sizeof(struct MarketGoods),1,fp)!=N

33、ULL)m+; fclose(fp); dN+1=goodscount.goods_price; for(u=1;uN;u+) for(j=u+1;j=N;j+) if(dudj)t=du;du=dj;dj=t; printf(商品信息:n); printf( 編號(hào) 名稱(chēng) 價(jià)格 折扣 總數(shù)目 剩余數(shù)目 n); for(u=1;u=N;u+) printf(%4d,du);void change() /*數(shù)據(jù)修改*/ FILE *fp;int i,m=0;char ch20,a20;fp=fopen(e:/student.txt,rt);while(fread(&goodsm,sizeof(st

34、ruct MarketGoods),1,fp)!=NULL)m+;fclose(fp);printf(nyou sure want change goodsInfor y/n): );/*根據(jù)商品的id來(lái)修改數(shù)據(jù)*/ scanf(%s,ch); if(strcmp(ch,y)=0|strcmp(ch,Y)=0) printf(nenter you want change goods_id:); scanf(%s,a); for(i=0;icount;i+) if(strcmp(goodsi.goods_id,a)=0) printf(nyou sure want change goods na

35、me(y/n): ); scanf(%s,ch); if(strcmp(ch,y)=0|strcmp(ch,Y)=0) printf(nname:);scanf(%s,goodsi.goods_name); printf(nyou sure want change goods price(y/n): ); scanf(%s,ch); if(strcmp(ch,y)=0|strcmp(ch,Y)=0) printf(nprice);scanf(%lf,&goodsi.goods_price); printf(nyou sure want goods discount(y/n): ); scanf

36、(%s,ch); if(strcmp(ch,y)=0|strcmp(ch,Y)=0) printf(ndiscount); scanf(%lf,&goodsi.goods_discount); printf(nyou sure want goods amount(y/n): ); scanf(%s,ch); if(strcmp(ch,y)=0|strcmp(ch,Y)=0) printf(namount);scanf(%d,&goodsi.goods_amount);printf(nyou sure want goods remain(y/n): ); scanf(%s,ch); if(str

37、cmp(ch,y)=0|strcmp(ch,Y)=0) printf(nremain); scanf(%d,&goodsi.goods_remain); fwrite(&goods,sizeof(struct MarketGoods),count,fp);fclose(fp);output();getch();system(cls);start();void dele() /*數(shù)據(jù)刪除*/FILE *fp;int i,m=0,j;char ch20,c20;fp=fopen(e:/student.txt,rt);while(fread(&goodsm,sizeof(struct MarketG

38、oods),1,fp)!=NULL)printf(%s,goodsm.goods_id);m+;fclose(fp);printf(nenter you want delete name :n); /*根據(jù)商品的名稱(chēng)來(lái)刪除數(shù)據(jù)*/ printf(name:); scanf(%s,c); for(i=0;icount;i+) if(strcmp(c,goodsi.goods_name)=0) break; /*找到,即跳出循環(huán)*/ for(j=i;jcount-1;j+) goodsj=goodsj+1; printf(tttyou had delete %sn,c); count-;fp=fopen(e:/student.txt,wt);fwrite(&goods,sizeof(struct MarketGoods),count,fp);fclose(fp);output();getch();

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論