C語言版商品庫存管理系統(tǒng).doc_第1頁
C語言版商品庫存管理系統(tǒng).doc_第2頁
C語言版商品庫存管理系統(tǒng).doc_第3頁
C語言版商品庫存管理系統(tǒng).doc_第4頁
C語言版商品庫存管理系統(tǒng).doc_第5頁
已閱讀5頁,還剩9頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領

文檔簡介

建議使用VS打開運行#pragma once#includetypedef struct information /商品信息 char number20; /編號 char sname20; /名稱 float price; /價格 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); /按編號查詢 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標頭.hvoid menu(inf *head) /顯示菜單 PlaySound(TEXT(sounds背景.wav), NULL, SND_FILENAME | SND_ASYNC | SND_LOOP); system(color 3B); printf(tt*n); printf(tttt歡迎進入商品庫存管理系統(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.按價格從高到低進行排序 |n); printf(tt|_0.釋放鏈表。退出_|); printf(nttt請輸入你的選項(0-8):n); printf(n); printf(t請輸入你的選擇: 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(請輸入:你想錄入多少個商品信息: n ); scanf(%d, &n); for (i = 1; i number); printf(名稱:); scanf(%s, p-sname); printf(價格:); 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(請輸入:你想添加多少個商品信息: n); scanf(%d, &n); for (i = 1; i number); printf(名稱:); scanf(%s, p-sname); printf(價格:); 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(鏈表為空,請先輸入信息!n); return; while (p != NULL) n+; printf(商品信息:編號: %s,名稱:%s,價格:%.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.按編號查詢n); printf(t 2.按名稱查詢n); printf(請輸入你的選擇:n); scanf(%d, &a); if (a = 1) chaxun_number(head);/調(diào)用按編號查詢的函數(shù) break; if (a = 2) chaxun_sname(head);/調(diào)用按名稱查詢的函數(shù) break; if (a != 1 & a != 2) printf(輸入錯誤!n); break; getchar(); void chaxun_number(inf *head) /按編號查詢 char num20; inf *p; int i = -1; p = head; printf(請輸入你要查詢的商品的編號:); scanf(%s, num); while (p-next != NULL) p = p-next; if (strcmp(p-number, num) = 0) i = 1; printf(已找到該商品信息n); printf(貨物信息:編號:%s,名稱:%s,價格:%.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(商品信息:編號:%s,名稱:%s,價格:%.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請輸入新的的編號,名稱,價格,數(shù)量:生產(chǎn)日期:n); printf(編號:); scanf(%s, p-number); printf(名稱:); scanf(%s, p-sname); printf(價格:); scanf(%f, &p-price); printf(數(shù)量:); scanf(%d, &p-count); printf(生產(chǎn)日期:); scanf(%s,p-dath); if (inext; if (p = NULL) printf(沒有商品信息,請先保存商品信息!n); printf(tt 請輸入要修改的內(nèi)容n); printf(tt 1.修改編號 2.修改名稱n); printf(tt 3.修改價格 4.修改數(shù)量n); printf(tt 5.修改生產(chǎn)日期n); printf(請選擇 n); scanf(%d, &b); switch (b) case 1: printf(請輸入原商品編號:n); scanf(%s, &number2); while (p != NULL) if (strcmp(p-number, number2) = 0) printf(已找到該商品n請輸入新的編號:n); scanf(%s, &p-number); p = p-next; printf(該商品信息已修改成功。n); break; case 2: printf(請輸入原名稱:n); scanf(%s, &name2); while (p != NULL) if (strcmp(p-sname, name2) = 0) printf(請輸入新的名稱:n); scanf(%s, &p-sname); break; p = p-next; printf(該商品信息已修改成功。n); break; case 3: printf(請輸入該商品編號:); scanf(%s,&number2); printf(請輸入原價格:n); scanf(%f, &price2); while (p != NULL) if (strcmp(p-number, number2) = 0&price2=p-price) printf(請輸入新的價格:n); scanf(%f, &p-price); break; p = p-next; printf(該商品信息已修改成功。n); break; case 4: printf(請輸入該商品編號:); scanf(%s,&number2); printf(請輸入被修改的數(shù)量:n); scanf(%d, &count2); while (p != NULL) if (count2 = p-count&strcmp(p-number, number2) = 0) printf(請輸入新的數(shù)量:n); scanf(%d, &p-count); break; p = p-next; printf(該商品信息已修改成功。n); break; default: printf(修改內(nèi)容有錯誤!n); void shanchu(inf *head) /刪除貨物信息 int a; printf(tt 1.按編號刪除 2.按名稱刪除n); printf(tt請輸入選項:n); scanf(%d, &a); switch (a) case 1: char number20; int i = -1; inf *p, *h; p = head; printf(請輸入你要刪除的商品的編號: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(不能打開文件!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. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論