freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

程序設(shè)計大作業(yè)代碼及說明書-圖書銷售管理系統(tǒng)(已修改)

2025-04-26 23:19 本頁面
 

【正文】 程序設(shè)計說明書(圖書銷售管理系統(tǒng)) 圖書銷售系統(tǒng):程序代碼include include includestruct book{ char ISBN[50]。 //ISBN號 char name[50]。 //圖書名稱 float price。 //價格 int store0。 //最初書店中的庫存 int store。 //當前存貨量 int sale。 //銷售量 char discount。 //是否促銷 struct book *next。 //單鏈表中指向下一結(jié)構(gòu)體首地址的指針}。int n。 //圖書數(shù)量,需要在錄入時從文件第一行讀取static struct book *bklist,bk[100]。 //圖書單鏈表的首地址,和圖書數(shù)組int judge(char a[]) // 要考慮到輸入非數(shù)字的的影響,若輸入的是正確的非負整數(shù)則返回該數(shù),否則返回1。在main函數(shù)中,將輸入內(nèi)容轉(zhuǎn)化為字符串{ int i,b,trns。 if(a[0]==39。039。amp。amp。a[1]!=39。\039。) { printf(請輸入正整數(shù)或0。)。 return 1。 } //1:排出輸入內(nèi)容中第一個字符為39。039。,之后還有別的內(nèi)容的情況 for (i=0。a[i]!=39。\039。i++) { b=a[i]。 if ((b48)||(b57)) { printf(請輸入正整數(shù)或0。\n\n)。 return 1。 } //2:若含數(shù)字外的字符,則返回1,說明用戶輸入有誤 } trns=atoi(a)。 //排除了2的情況后,將字符串轉(zhuǎn)化為整型數(shù),將該整型數(shù)返回 return trns。}void show(struct book *k) //用于顯示圖書的相關(guān)信息{ fprintf(stdout,%25s%%5d%10d%5c%30s\n\n,kISBN,kprice,kstore,ksale,kdiscount,kname)。}void ordershow(const char order[]) //用于提示用戶當前所在的命令操作界面{ printf(\n\n%s\n\n\n,order)。}void column(void) //用于顯示圖書信息表格的表頭{ printf( ISBN號 價格 庫存 銷售量 是否促銷 書名\n)。}struct book *create(FILE *p){ struct book *mylist,*tempnode,*cursor。int i。 mylist=(struct book *)malloc(sizeof(struct book))。 if (mylist==NULL) {printf(error1)。exit(1)。} mylistnext=NULL。 cursor=mylist。 fscanf(p,%d,amp。n)。 for(i=0。in。i++) { tempnode=(struct book *)malloc(sizeof(struct book))。 if (tempnode==NULL) {printf(error1)。exit(1)。} tempnodenext=NULL。 fscanf(p,%s %f %d %d %c,tempnodeISBN,amp。(tempnodeprice),amp。(tempnodestore0),amp。(tempnodestore),amp。(tempnodediscount))。 fgets(tempnodename,30,p)。 tempnodesale=tempnodestore0tempnodestore。 strcpy(bk[i].ISBN,tempnodeISBN)。strcpy(bk[i].name,tempnodename)。 bk[i].price=tempnodeprice。 bk[i].store0=tempnodestore0。bk[i].store=tempnodestore。 bk[i].sale=tempnodesale。 bk[i].discount=tempnodediscount。 //內(nèi)容錄入數(shù)組,數(shù)組是全局的,無需返回 cursornext=tempnode。 cursor=tempnode。 } //創(chuàng)建單鏈表,對數(shù)據(jù)進行錄入,同時錄入數(shù)組 cursor=NULL。tempnode=NULL。 return mylist。 //返回單鏈表首地址}void freellist(struct book *head){ struct book *ptr。 while (head!=NULL) // 遍歷鏈表 { ptr=head。 head = headnext。 // 指向下一節(jié)點 ptrnext=NULL。 free(ptr)。 // 釋放結(jié)構(gòu)體 }}int search(char *l){ struct book *booksearch。 for(booksearch=bklistnext。booksearch!=NULL。booksearch=booksearchnext) { if(strcmp(l,booksearchISBN)==0) { column()。 show(booksearch)。 booksearch=NULL。 return 0。 } } printf(抱歉,沒有找到相應(yīng)的圖書。\n\n)。 booksearch=NULL。 return 1。} //利用單鏈表進行ISBN查找void keyword(char a[]){ int i,j,k。 int length,lengthi,flag=0,flag1=0,temp,temp0。 length=strlen(a)。 //關(guān)鍵詞的長度 flag=0。flag1=0。 column()。 for(i=0。in。i++) { lengthi=strlen(bk[i].name)。 for(j=0。j+lengthlengthi。j++) { for(k=0。klength。k++) { temp=a[k]。temp0=bk[i].name[j+k]。 flag+=(temp0temp)*(temp0temp)。 } if(flag==0) { flag1++。show(amp。bk[i])。break。 } else flag=0。 } } if(flag1==0)printf(抱歉,沒有找到相應(yīng)的圖書。\n\n)。 } //關(guān)鍵詞查找:查找結(jié)果為書名中包含查找內(nèi)容(作為整體)的相應(yīng)書籍的全部內(nèi)容void bubblesort(void){ int i。 struct book *a,*b,*c。 ordershow(銷量由高到低排序)。 for(i=0。in。i++) for (a=bklist。anextnext!=NULL。a=anext) { b=anext。c=bnextnext。 if (bsalebnextsale) { anext=bnext。 anextnext=b。 bnext=c。 } } column()。for(c=bklistnext。c!=NULL。c=cnext) { show(c)。 } c=NULL。b=NULL。a=NULL。} //用單鏈表進行冒泡排序,打印出按照銷量由高到低的排行榜void selectsort(struct book a[]){int i,j,min。struct book *pb[50],*tempb。ordershow(價格由低到高排行)。for (i=0。in。i++) pb[i]=amp。a[i]。for(i=0。in。i++) { min=i。 for(j=i。jn。j++) { if(pb[min]pricepb[j]price) min=j。 } tempb=pb[i]。pb[i]=pb[min]。pb[min]=tempb。 }column()。for (i=0。in。i++) show(pb[i])。tempb=NULL。for(i=0。i49。i++) pb[i]=NULL。} //對圖書數(shù)組進行選擇排序,打印出圖書價格由低到高的排行榜void insertsort(struct book a[]){ int i,j。 struct book *tempc,*pc[50]。 ordershow(庫存由低到高排行)。 for (i=0。in。i++) pc[i]=amp。a[i]。 for (i=1。in。i++) { tempc=pc[i]。 for(j=i1。(j=0)amp。amp。(tempcstorepc[j]store)。j) pc[j+1]=pc[j]。 pc[j+1]=tempc。 } column()。 for (i=0。in。i++) show(pc[i])。 tempc=NULL。for(i=0。i49。i++) pc[i]=NULL。} //對圖書數(shù)組進行選擇排序,打印出圖書庫存由低到高的排行榜void main(){ FILE *p。 int i,op,operat,booknum。char ISBN0[100],buy[100],back[100],str[100]。 //從左到右依次為:查詢圖書的ISBN碼,購買圖書的ISBN碼,退還圖書的ISBN碼,接受用戶輸入的操作命令的
點擊復(fù)制文檔內(nèi)容
公司管理相關(guān)推薦
文庫吧 www.dybbs8.com
公安備案圖鄂ICP備17016276號-1