




已閱讀5頁(yè),還剩9頁(yè)未讀, 繼續(xù)免費(fèi)閱讀
版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
建議使用VS打開(kāi)運(yùn)行#pragma once#includetypedef struct information /商品信息 char number20; /編號(hào) char sname20; /名稱 float price; /價(jià)格 int count; /數(shù)量 char dath20; /生產(chǎn)日期 struct information *next;inf;void menu(inf *head); /顯示主菜單 inf *create(); /創(chuàng)建鏈表 void Input(inf *head); /輸入商品信息 void tianjia(inf *head); /添加商品信息 void output(inf *head); /輸出商品信息 void chaxun(inf *head); /查詢商品信息void chaxun_number(inf *head); /按編號(hào)查詢 void chaxun_sname(inf *head); /按名稱查詢 void xiugai(inf *head); /修改商品信息 void shanchu(inf *head); /刪除商品信息 void write_file(inf *head); /保存商品信息到文件 void paixu(inf *head);inf *Read_file(); /讀取文件內(nèi)商品信息 void freeh(inf *head); /退出程序 #define _CRT_SECURE_NO_WARNINGS#include #include #include #include #include #include #pragma comment(lib, WINMM.lib)#include標(biāo)頭.hvoid menu(inf *head) /顯示菜單 PlaySound(TEXT(sounds背景.wav), NULL, SND_FILENAME | SND_ASYNC | SND_LOOP); system(color 3B); printf(tt*n); printf(tttt歡迎進(jìn)入商品庫(kù)存管理系統(tǒng)n); printf(tt*n); printf(n); printf(tt|=|n); printf(tt|_基本信息_|n); printf(tt| 1.商品信息錄入 | 2.添加商品信息 |n); printf(tt| 3.查找商品信息 | 4.修改商品信息 |n); printf(tt| 5.刪除商品信息 | 6.保存文件信息 |n); printf(tt| 7.讀取文件信息 | 8.顯示商品信息 |n); printf(tt| 9.按價(jià)格從高到低進(jìn)行排序 |n); printf(tt|_0.釋放鏈表。退出_|); printf(nttt請(qǐng)輸入你的選項(xiàng)(0-8):n); printf(n); printf(t請(qǐng)輸入你的選擇: n);inf *create() /創(chuàng)建鏈表 inf *p; p = (inf *)malloc(sizeof(struct information); if (p = NULL) printf(鏈表創(chuàng)建失敗.n); exit(0); p-next = NULL; return (p);void Input(inf *head) /錄入貨物信息 inf *p; int i,n; printf(請(qǐng)輸入:你想錄入多少個(gè)商品信息: n ); scanf(%d, &n); for (i = 1; i number); printf(名稱:); scanf(%s, p-sname); printf(價(jià)格:); scanf(%f, &p-price); printf(數(shù)量:); scanf(%d, &p-count); printf(生產(chǎn)日期:); scanf(%s,p-dath); p-next = NULL; while (head-next != NULL) head = head-next; head-next = p; void tianjia( inf *head) /添加貨物信息 inf *p; int i,n; printf(請(qǐng)輸入:你想添加多少個(gè)商品信息: n); scanf(%d, &n); for (i = 1; i number); printf(名稱:); scanf(%s, p-sname); printf(價(jià)格:); scanf(%f, &p-price); printf(數(shù)量:); scanf(%d, &p-count); printf(生產(chǎn)日期:); scanf(%s,p-dath); p-next = NULL; while (head-next != NULL) head = head-next; head-next = p; void output(inf *head) /輸出貨物信息 int n = 0; inf *p; p = head-next; if (p = NULL) printf(鏈表為空,請(qǐng)先輸入信息!n); return; while (p != NULL) n+; printf(商品信息:編號(hào): %s,名稱:%s,價(jià)格:%.2f 數(shù)量:%d 生產(chǎn)日期:%sn, p-number, p-sname, p-price, p-count,p-dath); p = p-next; printf(商品總數(shù)為:%d n, n);void chaxun(inf *head) /查詢貨物信息 函數(shù) int a; printf(tt查詢信息n); while (1) printf(t 1.按編號(hào)查詢n); printf(t 2.按名稱查詢n); printf(請(qǐng)輸入你的選擇:n); scanf(%d, &a); if (a = 1) chaxun_number(head);/調(diào)用按編號(hào)查詢的函數(shù) break; if (a = 2) chaxun_sname(head);/調(diào)用按名稱查詢的函數(shù) break; if (a != 1 & a != 2) printf(輸入錯(cuò)誤!n); break; getchar(); void chaxun_number(inf *head) /按編號(hào)查詢 char num20; inf *p; int i = -1; p = head; printf(請(qǐng)輸入你要查詢的商品的編號(hào):); scanf(%s, num); while (p-next != NULL) p = p-next; if (strcmp(p-number, num) = 0) i = 1; printf(已找到該商品信息n); printf(貨物信息:編號(hào):%s,名稱:%s,價(jià)格:%.2f.數(shù)量:%d,生產(chǎn)日期:%sn, p-number, p-sname, p-price, p-count,p-dath); if (inext != NULL) p = p-next; if (strcmp(p-sname, a) = 0) i = 1; printf(已找到該商品信息n); printf(商品信息:編號(hào):%s,名稱:%s,價(jià)格:%.2f.數(shù)量:%d,生產(chǎn)日期n, p-number, p-sname, p-price, p-count,p-dath); if (inext != NULL) p = p-next; if (strcmp(p-number, no) = 0) i = 1; printf(已找到該商品n請(qǐng)輸入新的的編號(hào),名稱,價(jià)格,數(shù)量:生產(chǎn)日期:n); printf(編號(hào):); scanf(%s, p-number); printf(名稱:); scanf(%s, p-sname); printf(價(jià)格:); scanf(%f, &p-price); printf(數(shù)量:); scanf(%d, &p-count); printf(生產(chǎn)日期:); scanf(%s,p-dath); if (inext; if (p = NULL) printf(沒(méi)有商品信息,請(qǐng)先保存商品信息!n); printf(tt 請(qǐng)輸入要修改的內(nèi)容n); printf(tt 1.修改編號(hào) 2.修改名稱n); printf(tt 3.修改價(jià)格 4.修改數(shù)量n); printf(tt 5.修改生產(chǎn)日期n); printf(請(qǐng)選擇 n); scanf(%d, &b); switch (b) case 1: printf(請(qǐng)輸入原商品編號(hào):n); scanf(%s, &number2); while (p != NULL) if (strcmp(p-number, number2) = 0) printf(已找到該商品n請(qǐng)輸入新的編號(hào):n); scanf(%s, &p-number); p = p-next; printf(該商品信息已修改成功。n); break; case 2: printf(請(qǐng)輸入原名稱:n); scanf(%s, &name2); while (p != NULL) if (strcmp(p-sname, name2) = 0) printf(請(qǐng)輸入新的名稱:n); scanf(%s, &p-sname); break; p = p-next; printf(該商品信息已修改成功。n); break; case 3: printf(請(qǐng)輸入該商品編號(hào):); scanf(%s,&number2); printf(請(qǐng)輸入原價(jià)格:n); scanf(%f, &price2); while (p != NULL) if (strcmp(p-number, number2) = 0&price2=p-price) printf(請(qǐng)輸入新的價(jià)格:n); scanf(%f, &p-price); break; p = p-next; printf(該商品信息已修改成功。n); break; case 4: printf(請(qǐng)輸入該商品編號(hào):); scanf(%s,&number2); printf(請(qǐng)輸入被修改的數(shù)量:n); scanf(%d, &count2); while (p != NULL) if (count2 = p-count&strcmp(p-number, number2) = 0) printf(請(qǐng)輸入新的數(shù)量:n); scanf(%d, &p-count); break; p = p-next; printf(該商品信息已修改成功。n); break; default: printf(修改內(nèi)容有錯(cuò)誤!n); void shanchu(inf *head) /刪除貨物信息 int a; printf(tt 1.按編號(hào)刪除 2.按名稱刪除n); printf(tt請(qǐng)輸入選項(xiàng):n); scanf(%d, &a); switch (a) case 1: char number20; int i = -1; inf *p, *h; p = head; printf(請(qǐng)輸入你要?jiǎng)h除的商品的編號(hào):n); scanf(%s, number); while (p-next != NULL) if (strcmp(number, p-next-number) = 0) i = 1; h = p-next; p-next = p-next-next; free(h); printf(已刪除該商品信息。n); break; p = p-next; if (inext != NULL) if (strcmp(name, p-next-sname) = 0) i = 1; h = p-next; p-next = p-next-next; free(h); printf(已刪除該商品信息。n); break; p = p-next; if (inext != NULL) p = p-next; fwrite(p, sizeof(struct information), 1, fp); fclose(fp);inf *Read_file() /讀取文件內(nèi)的貨物信息 inf *p, *d, *head; FILE *fp; head = (inf *)malloc(sizeof(struct information); p = (inf *)malloc(sizeof(struct information); if (fp = fopen(商品信息.txt, rb) = NULL) printf(不能打開(kāi)文件!n); exit(0); if (fread(head, sizeof(struct information), 1, fp) d = head; while (fread(p, sizeof(struct information), 1, fp) d-next = p; d = p; p = (inf *)malloc(sizeof(struct information); d -next = NULL; fclose(fp); return (head);void freeh(inf *head) /釋放空間 退出程序 inf *p; p = (inf *)malloc(sizeof(struct information); p = head; while (head-next != NULL) head = head-next; free(p); p = head; free(p);void paixu(inf *head) inf *p=head,*q=NULL,*t=NULL,*subhead=NULL; int i, j, count = 0; while (p-next != NULL) count+; p = p-next; for (i = 0; i next; q = p-next; for (j = 0; j price price) subhead-next = p-next; p-next = q-next; q-next = p; t= p; p = q; q = t; subhead = subhead-next; p = p-next; q = q-next; output(head);int main() i
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 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ì)用戶上傳內(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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 小學(xué)語(yǔ)文線上線下教學(xué)銜接多元評(píng)價(jià)計(jì)劃
- 初中學(xué)校心理健康支持系統(tǒng)建設(shè)計(jì)劃
- 高一英語(yǔ)考試備考計(jì)劃
- 膳食委員會(huì)健康飲食宣傳計(jì)劃范文
- 軀干血管畸形護(hù)理課件
- 中毒性肝炎的護(hù)理查房
- 小學(xué)三年級(jí)下冊(cè)道德與法治綜合實(shí)踐計(jì)劃
- 小學(xué)六年級(jí)足球裝備采購(gòu)計(jì)劃
- 2025年小學(xué)教導(dǎo)處春季安全教育計(jì)劃
- 七年級(jí)英語(yǔ)線上線下教學(xué)活動(dòng)銜接計(jì)劃
- 污水處理廠化驗(yàn)室管理
- 四川省遂寧市(2024年-2025年小學(xué)四年級(jí)語(yǔ)文)人教版期末考試((上下)學(xué)期)試卷及答案
- 游戲行業(yè)的數(shù)據(jù)分析和決策支持
- DL∕T 1084-2021 風(fēng)力發(fā)電場(chǎng)噪聲限值及測(cè)量方法
- 一元二次方程因式分解法練習(xí)100題及答案
- 護(hù)用藥理學(xué)知識(shí)點(diǎn)
- 住院成人高血糖患者血糖監(jiān)測(cè)醫(yī)護(hù)協(xié)議處方共識(shí)
- 古希臘文明智慧樹(shù)知到期末考試答案章節(jié)答案2024年復(fù)旦大學(xué)
- 2024年江蘇省南通市如東縣政府購(gòu)買(mǎi)崗招聘92人重點(diǎn)基礎(chǔ)提升難、易點(diǎn)模擬試題(共500題)附帶答案詳解
- 2024年廣東省廣州市天河區(qū)七年級(jí)(下)期末數(shù)學(xué)試卷含答案
- 福建省廈門(mén)市廈門(mén)一中2024年數(shù)學(xué)高一下期末質(zhì)量檢測(cè)試題含解析
評(píng)論
0/150
提交評(píng)論