




已閱讀5頁,還剩11頁未讀, 繼續(xù)免費(fèi)閱讀
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
重慶科技學(xué)院C語言程序設(shè)計(jì)課程設(shè)計(jì)報(bào)告#include #include #include #include #include int bgnumber = 023; /客戶號(hào)int inumber = 0; /商品量的統(tǒng)計(jì)int ibuy = 0; /訂單的統(tǒng)計(jì)void secondmain();/管理維護(hù)子菜單void jianpanload(); /輸入商品void scanproduct(); /瀏覽商品void searchproduct(); /搜索商品void dinggou(); /訂購商品void lookdinggou(); /查詢訂單void addproduct(); /增加商品void deleteproduct(); /刪除商品void saveproduct(); /保存商品void savedinggou(); /保存訂單void wenbenload(); /從文本導(dǎo)入商品struct productchar name30;/商品名int number;/貨號(hào)char vender30;/廠家char filed100;/產(chǎn)地int stock;/存量double unvalent;/單價(jià);struct product a100;struct dinggou int bgname; /貨號(hào)int bmany; /訂購量int btime; /日期時(shí)間char bname100; /客戶名char baddress100; /客戶地址int bnumber; /客戶號(hào);struct dinggou b100;int main(void)int i;wenbenload();dosystem(cls);printf(nnnnnn);printf(*歡迎使用商品訂購系統(tǒng)v1.0*n);printf( 作者: 計(jì)科1102 姚茂源n);printf( n);printf( 1.瀏覽商品信息 n);printf( 2.訂購商品 n);printf( 3.訂單查詢 n);printf( 4.搜索商品 n);printf( 5.管理菜單 n);printf( 0.退出系統(tǒng) n);printf( n);printf(*n);printf(nntt請輸入你的操作(05): );scanf(%d,&i); switch(i)case 1: system(cls);scanproduct(); break;case 2: system(cls); dinggou(); break;case 3: system(cls);lookdinggou();break;case 4: searchproduct();break;case 5: secondmain();break;case 0: /退出系統(tǒng)的界面system(cls);printf(nnnnnnnn); printf(nnttt歡迎使用本系統(tǒng)nnnnnttt歡迎再次使用n);exit(0); /exit用于在程序運(yùn)行的過程中隨時(shí)結(jié)束程序 while(1); return 0;/瀏覽商品void scanproduct()int i;system(cls);printf(ttttt商品信息列表n); for (i = 0; i inumber; i+)printf(名稱 : %sn,);printf(貨號(hào) : %dn,ai.number);printf(廠家 : %sn,ai.vender);printf(產(chǎn)地 : %sn,ai.filed);printf(存量 : %dn,ai.stock);printf(單價(jià) : %.2lfnnn,ai.unvalent);printf(nnnnnnttt);printf(返回主菜單n);printf(ttt);system(pause);return;/商品的訂購void dinggou() char ch;int i, j, t, c = 1;int n = 1;int m = 0;doswitch(n)case 1:system(cls);printf(tttt商品信息列表n);/顯示商品的名稱、貨號(hào)信息,以便于訂購printf(名稱t 貨號(hào)t 庫存n);for (i = 0; i inumber; i+)printf(%st %dt %dnnn,,ai.number,ai.stock);printf(nnn);printf(tttt商品訂單n);printf(nttt請輸入你的第%d個(gè)訂單信息:n,m + 1);printf(nttt貨號(hào):);fflush(stdin);scanf(%d,&bibuy.bgname);/檢測是否含有此商品j = 1;for (i = 0; i = bibuy.bmany)at.stock = at.stock - bibuy.bmany; /顧客購買后商品的庫存計(jì)算printf(nttt日期時(shí)間:);fflush(stdin);scanf(%d,&bibuy.btime);printf(nttt客戶名:);fflush(stdin);gets(bibuy.bname);printf(nttt客戶地址:);fflush(stdin);gets(bibuy.baddress);printf(nttt客戶號(hào):);bibuy.bnumber = bgnumber;printf(%dn,bibuy.bnumber);bgnumber+;ibuy+;m+;printf(nnntttt);system(pause);elseprintf(nnttt訂購數(shù)目超出庫存n);printf(ttt);system(pause);/若沒有商品的提示及操作elseprintf(nnttt查無此貨n);printf(ttt);system(pause);case 2:printf(是否繼續(xù)輸入訂購?(Y/N);fflush(stdin);scanf(%c,&ch);if(ch = N | ch = n)c = 0;break;else if(ch = Y | ch = y)c = 0;n = 1;break;else if(ch != n | ch != N | ch != Y | ch != y)n = 0;c = 1;break;case 0:if(c = 1)n = 2;while(ch != n & ch != N);system(cls);return ;/訂單的查詢void lookdinggou() int i;system(cls);printf(ttttt訂單列表n); for (i = 0; i ibuy; i+)printf(貨號(hào) : %dn,bi.bgname);printf(訂購量 : %dn,bi.bmany);printf(日期時(shí)間 : %dn,bi.btime);printf(客戶名 : %sn,bi.bname);printf(客戶地址 : %sn,bi.baddress);printf(客戶號(hào) : %dnnn,bi.bnumber);printf(nnnnnnttt);printf(返回主菜單n);printf(ttt);system(pause);return;/增加商品void addproduct() char ch; int i=1;int n = 1;do switch(n)case 1:system(cls);printf(tttt商品信息的增加n);printf(ttttt注:要重新輸入已有及增加的商品n);printf(nttt請輸入你的第%d件商品的信息:n,i);printf(nttt名稱:);fflush(stdin);scanf(%s,);printf(nttt貨號(hào):);fflush(stdin);scanf(%d,&ainumber.number);printf(nttt廠家:);fflush(stdin);scanf(%s,ainumber.vender);printf(nttt產(chǎn)地:);fflush(stdin);scanf(%s,ainumber.filed);printf(nttt存量:);fflush(stdin);scanf(%d,&ainumber.stock);printf(nttt單價(jià):);fflush(stdin);scanf(%lf,&ainumber.unvalent);i+;inumber+;case 2:printf(是否繼續(xù)輸入記錄?(Y/N);fflush(stdin);scanf(%c,&ch);if(ch = N | ch = Y| ch = n| ch = y)break;if(ch = Y| ch = y)n = 1;break;case 0:printf(是否繼續(xù)輸入記錄?(Y/N);fflush(stdin);scanf(%c,&ch);n = 2;while(ch != n & ch != N);return;/刪除商品void deleteproduct()int i;int j;char ch;int n = 1;doswitch(n)case 1:system(cls);printf(tttt商品列表n);/顯示商品的名稱、貨號(hào)信息,以便于下部的刪除for (i = 0; i inumber; i+)printf(名稱 : %sn,);printf(ID : %dn,i);printf(庫存 : %dnnn,ai.stock);/商品的搜索printf(nnntttt請輸入你要?jiǎng)h除商品的ID:);scanf(%d,&j);i = j;while(i inumber - 1)strcpy(, ai + 1.name); ai.number = ai + 1.number; strcpy(ai.filed, ai + 1.filed); ai.stock = ai + 1.stock; ai.unvalent = ai + 1.unvalent;strcpy(ai.vender, ai + 1.vender);i+;inumber-;case 2:printf(是否繼續(xù)刪除商品?(Y/N);fflush(stdin);scanf(%c,&ch);if(ch = N | ch = Y| ch = n| ch = y)break;if(ch = Y| ch = y)n = 1;break;case 0:printf(是否繼續(xù)輸入記錄?(Y/N);fflush(stdin);scanf(%c,&ch);n = 2;while(ch != n & ch != N);printf(nnnnnnttt);printf(返回附加功能菜單n);printf(ttt);system(pause);return;/商品信息的保存void saveproduct()FILE *fpgoods;int i;fpgoods = fopen(goodsinfo.out,w);assert(fpgoods != NULL); fprintf(fpgoods,tttttt商品信息列表n);/商品信息的錄入for (i = 0; i inumber; i+)fprintf(fpgoods,名稱: %sn,);fprintf(fpgoods,貨號(hào): %dn,ai.number);fprintf(fpgoods,廠家: %sn,ai.vender);fprintf(fpgoods,產(chǎn)地: %sn,ai.filed);fprintf(fpgoods,存量: %dn,ai.stock);fprintf(fpgoods,單價(jià): %.2lfnnn,ai.unvalent);fclose(fpgoods);system(cls);printf(nnnnnntttt商品信息保存成功!n);printf(tttt);system(pause);return;/訂單的保存信息void savedinggou()FILE *fpgoods;int i;fpgoods = fopen(bookrecordinfo.out,w);assert(fpgoods != NULL);fprintf(fpgoods,tttttt訂單列表n);/商品信息的錄入for (i = 0; i ibuy; i+)fprintf(fpgoods,貨號(hào) :%dn,bi.bgname);fprintf(fpgoods,訂購量 :%dn,bi.bmany);fprintf(fpgoods,日期時(shí)間 :%dn,bi.btime);fprintf(fpgoods,客戶名 :%sn,bi.bname);fprintf(fpgoods,客戶地址 :%sn,bi.baddress);fprintf(fpgoods,客戶號(hào) :%dnnn,bi.bnumber);fclose(fpgoods);/保存后信息的反饋system(cls);printf(nnnnnntttt信息保存成功!n);printf(tttt);system(pause);return; /管理維護(hù)子菜單void secondmain()int i;dosystem(cls);printf(nnnnnnn);printf(*管理維護(hù)子菜單*nn);printf( n);printf( 1.輸入全部商品 n);printf( 2.增加商品 n);printf( 3.刪除商品 n);printf( 4.儲(chǔ)存商品 n);printf( 5.儲(chǔ)存訂單 n);printf( 0.返回上一級(jí) n);printf( nnn);printf(*nnnnn);printf(nntt請輸入你所要選擇的功能(05): );scanf(%d,&i); switch(i)case 1: system(cls);jianpanload ();break;case 2: system(cls); addproduct(); break;case 3: system(cls); deleteproduct(); break;case 4: system(cls); saveproduct(); break;case 5: system(cls); savedinggou(); break;case 0: system(cls);return ; while(1);printf(tttt);system(pause);system(cls);return;/從鍵盤輸入商品void jianpanload()char ch;int n = 1;inumber = 0;do switch(n)case 1: /商品的錄入system(cls);printf(tttt請重新輸入全部商品信息n);printf(nttt請輸入第%d件商品的信息:n,inumber + 1);printf(nttt名稱:);fflush(stdin);gets();printf(nttt貨號(hào):);fflush(stdin);scanf(%d,&ainumber.number);printf(nttt廠家:);fflush(stdin);gets(ainumber.vender);printf(nttt產(chǎn)地:);fflush(stdin);gets(ainumber.filed);printf(nttt存量:);fflush(stdin);scanf(%d,&ainumber.stock);printf(nttt單價(jià):);fflush(stdin);scanf(%lf,&ainumber.unvalent);inumber+;fflush(stdin);case 2:printf(是否繼續(xù)輸入記錄?(Y/N);fflush(stdin);scanf(%c,&ch);if(ch = N | ch = Y| ch = n| ch = y)break;if(ch = Y| ch = y)n = 1;break;case 0:printf(是否繼續(xù)輸入記錄?(Y/N);fflush(stdin);scanf(%c,&ch);n = 2;while(ch != n & ch != N);return;/導(dǎo)入商品信息void wenbenload()FILE *fp;char ch30;double dou;int in;int i = 0;inumber = 0;fp = fopen(goodsinfo.out,r);assert(fp); /從文件中導(dǎo)入商品信息fscanf(fp,%s,&ch);while(fscanf(fp,%s,&ch) != EOF)fscanf(fp, %s, &ch);strcpy(, ch);fscanf(fp,%s,&ch);fscanf(fp,%d,&in);ainumber.number = in;fscanf(fp,%s,&ch);fscanf(fp,%s,&ch);strcpy(ainumber.vender, ch);fscanf(fp,%s,&ch);fscanf(fp,%s,&ch);strcpy(ainumber.filed, ch);fs
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(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ǔ)空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 二零二五年度辦公用品銷售折扣及定制服務(wù)合同
- 二零二五年度燃料研發(fā)與專利許可合同
- 二零二五年度股權(quán)代持合同:包含企業(yè)資產(chǎn)重組的綜合性協(xié)議
- 2025年度環(huán)保設(shè)施勞務(wù)分包安全責(zé)任協(xié)議
- 二零二五年度頂管施工安全教育與應(yīng)急預(yù)案制定合同
- 二零二五年度合資企業(yè)股份代持與清算協(xié)議
- 二零二五年度特色餐飲服務(wù)人員勞動(dòng)合同范本
- 二零二五年度地質(zhì)鉆孔施工環(huán)境保護(hù)協(xié)議
- 二零二五年度集體勞動(dòng)合同在民營企業(yè)中的創(chuàng)新
- 二零二五年度企業(yè)產(chǎn)品售后服務(wù)宣傳片委托協(xié)議
- 創(chuàng)傷傷口包扎術(shù)(加壓包扎止血法)技術(shù)操作考核評分標(biāo)準(zhǔn)
- 7S管理標(biāo)準(zhǔn)目視化管理標(biāo)準(zhǔn)
- 談書畫裝裱的歷史與現(xiàn)實(shí)
- 無線網(wǎng)絡(luò)技術(shù)復(fù)習(xí)題網(wǎng)絡(luò)與通信
- 口腔健康與全身健康課件
- 人教版九年級(jí)化學(xué)上冊第四單元作業(yè)設(shè)計(jì) 自然界的水
- 腦血管造影病人的護(hù)理-課件
- 阿里巴巴管理精髓管理者必修的24招
- 醫(yī)務(wù)科輪轉(zhuǎn)人員規(guī)定
- 統(tǒng)編版一年級(jí)語文下冊 口語交際 聽故事講故事 小貓種魚 一等獎(jiǎng)創(chuàng)新教學(xué)設(shè)計(jì)
- 普通地質(zhì)學(xué)教材
評論
0/150
提交評論