




版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
C言圖管系統(tǒng)碼
———————————————————————————————作:———————————————————————————————日:2
#include<stdio.h>#include<stdlib.h>#include<string.h>structbook{intwname[20];press[50];intfloatstructbook*next;};structbook*creatbook();//創(chuàng)鏈表structbook*addbook(structbook//添加圖書intyanzheng(structbookm);//驗新加的圖書編碼是否已存在void*head);//刪圖書voidfprint(struct*head);//將鏈表寫入文件structbook*load();//從件中讀取信息并建成鏈表voidprint_book(struct*head);//將表信息輸出voidchaxun(structbook//查圖書信息voidnum_chaxun(structbook*head);//按書編號查詢圖書voidbook//按者名查圖書void*head);//按類別查詢書voidbook//按版時間查詢圖書voidbname_chaxun(structbook按書名查詢圖書voidxiugai(structbook*head);//修改書信息voidpaixu(structbook//對圖書進行排序voidbook*head);//按書編號排序voidtime_paixu(struct*head);按書出版時間排序voidprice_paixu(structbook*head);//按圖書價格序voidbook//按書名排序void*head);按作者排序int{intchoice,n,x,y=1,c,c1=1234;a,d,b[10],b1[10]="yjk";structbookprintf("\n\n\n\n\n\n\n");**********歡迎光臨**********\n\n");**********************圖書信息管理3
************************\n\n\n");printf("\n\n");用登===========\n");退系===========\n");
請輸入您的選擇:printf("\n");getchar();switch(n){break;gets(b);printf("\n");
請輸入您的用戶:請輸入您的密碼:printf("\n");if(strcmp(b,b1)!=0||c!=c1){getchar();}else{getchar();
驗證失敗請重新輸入!\n");驗證通過!請按進!\n");------------------\n");*圖書信息管理系統(tǒng)*\n");------------------\n\n");**********************************************\n\n");**********************************************\n\n");添加圖書
刪除圖書||\n\n");圖書列表
圖書排序||\n\n");4
查詢圖書||\n\n");錄入數(shù)據(jù)||\n\n");**********************************************\n\n");**********************************************\n\n");printf("請入所選擇的序號:getchar();switch(choice){if(head==NULL){printf("文件為空請先錄入數(shù)據(jù)!\n");getchar();break;}else{head=addbook(head);printf("加成功!\n");printf("是將信息保存到文?scanf("%c",&a);getchar();switch(a){'n':break;fprint(head);printf("存成功!\n");getchar();break;}break;}if(head==NULL){5
修改圖書退出系統(tǒng)
printf("件為空請先錄入數(shù)據(jù)!\n");getchar();break;}else{getchar();break;}break;if(head==NULL){printf("件為空請先錄入數(shù)據(jù)!\n");getchar();break;}else{getchar();break;}if(head==NULL){printf("件為空請先錄入數(shù)據(jù)!\n");getchar();break;}else{paixu(head);getchar();}break;if(head==NULL){printf("件為,先錄入數(shù)據(jù)\n");getchar();break;}else{chaxun(head);6
getchar();}break;if(head==NULL){printf("件為空,先錄入數(shù)據(jù)!\n");getchar();break;}else{xiugai(head);getchar();break;}break;printf("意:入圖書編碼為時束\n");head=creatbook();printf("是將輸入的信息保存到文件以覆蓋文件中已存在的信息(y/n)\n");getchar();scanf("%c",&a);getchar();switch(a){'n':break;fprint(head);printf("存成功!\n");getchar();break;}break;printf("的輸入有,請新輸入\n");getchar();break;}}}break;7
getchar();break;
您的輸入有誤!請重新輸入!\n");}}}//錄入數(shù)據(jù)并形成鏈表structbook*creatbook(){structbook*head,*tail,*p;intnum,time,n;floatintsize=sizeof(structbook);head=tail=NULL;printf("輸入圖書編:scanf("%d",&num);printf("輸入圖書名:scanf("%s",bname);getchar();printf("輸入作者名:getchar();printf("輸入出版社:getchar();printf("輸入類別:getchar();printf("輸入出版時:getchar();printf("輸入價:getchar();while(1){p=(structbookp->num=num;strcpy(p->wname,wname);strcpy(p->press,press);p->time=time;8
p->next=NULL;if(head==NULL)head=p;printf("輸入圖書編號:scanf("%d",&num);n=yanzheng(head,num);break;printf("輸入的編號已存請重新輸入!\n");}while(1);if(num==0)break;{printf("輸入圖書名:scanf("%s",bname);getchar();printf("輸入作者名:getchar();printf("輸入出版社:getchar();printf("輸入類別:getchar();printf("輸入出版時:getchar();printf("輸入價格:getchar();}}head;}//插入結點,并且插入后仍按一定序structbook*addbook(structbook9
{structbook*ptr,*p1,*p2,*p;intsize=sizeof(structbook);intfloatprintf("輸入圖書編號:scanf("%d",&num);n=yanzheng(head,num);break;printf("輸入的編號已存請重新輸入!\n");}while(1);printf("輸入圖書名:scanf("%s",bname);getchar();printf("輸入作者名:getchar();printf("輸入出版社:getchar();printf("輸入類別:getchar();printf("輸入出版時:getchar();printf("輸入價:getchar();p=(structbookp->num=num;strcpy(p->wname,wname);strcpy(p->press,press);p->time=time;p2=head;10
while((ptr->num>p2->num)&&(p2->next!=NULL)){}if(ptr->num<=p2->num){else{p1->next=ptr;p->next=p2;}}else{p2->next=ptr;p->next=NULL;}head;}//驗證添加的圖書編號是否已存在intyanzheng(structbookm){structbookp=head;if(p->num==m)break;}if(p==NULL)0;1;}//將新鏈表寫入文件中voidfprint(struct{FILE*fp;structbook*p1;printf("Fileerror!\n");}11
fputc(ch,fp);for(p1=head;p1;p1=p1->next){fprintf(fp,"%d%d%f\n",p1->num,p1->bname,p1->wname,p1->press,p1->sort}fclose(fp);}//從文件中讀取圖書信息structbook*load(){FILE*fp;ch;structbook*head,*tail,*p1;head=tail=NULL;printf("Fileerror!\n");}if(ch=='1'){*)malloc(sizeof(structtime,&p1->price);if(head==NULL)head=p1;tail->next=p1;tail=p1;}fclose(fp);head;}NULL;}//將整個鏈表的信息輸出voidprint_book(struct{12
structbook*ptr;if(head==NULL){printf("\n沒信息!\n");return;}
圖書信息列表如下\==========================================================\n");
編號圖名作名出社類出版時間
價格\n");for(ptr=head;ptr;ptr=ptr->next)%s%d==========================================================\n");}//刪除圖書信息void{inta;b,ch='1';structbook*p1,*p2;FILE*fp;printf("輸入要刪除的圖書編:p1=head;if(p1->num==a&&p1->next==NULL){//對文件中只有一組數(shù)據(jù)printf("否清空文件!(y/n)\n");getchar();getchar();switch(b){'n':break;printf("Fileerror!\n");}fclose(fp);printf("件已清空!\n");}13
}else{while(p1->num!=a&&p1->next!=NULL){}if(p1->next==NULL){p2->next=NULL;printf("是確定從文件中徹底刪該圖?(y/n)\n");getchar();switch(b){'n':break;fprint(head);printf("除成功!\n");getchar();break;}}else{printf("沒找到要刪除的數(shù)!getchar();}}if(p1==head){head=p1->next;printf("否確定從文件中徹底刪除該圖(y/n)\n");getchar();switch(b){'n':break;fprint(head);printf("刪成功!getchar();break;14
}}else{p2->next=p1->next;printf("否確定從文件中徹底刪除該圖(y/n)\n");getchar();switch(b){'n':break;fprint(head);printf("刪成功!getchar();break;}}}}//圖書查詢voidchaxun(structbook*head){inta;==========================================================\n");**按圖書編號查詢2-按圖書名查詢**\n");**按圖書類別查詢4-按作者名查詢**\n");**按出版時間查詢0-退出查詢**\n");==========================================================\n");printf("輸入所選擇的編:getchar();switch(a){break;break;bname_chaxun(head);15
break;break;break;break;printf("的輸入有誤!\n");break;}}//按編號查詢圖書信息voidnum_chaxun(structbook*head){inta;structbookprintf("選擇您要查詢的圖書編號");getchar();p=head;if(p->num==a)break;}if(p==NULL){printf("有找到該編號的圖書!\n");}else{
你所查詢的圖書信息如下\n");=========================================================================\n");**編號圖書名作名出社類別出時間價格**\n");**%s%s%s%.2f**\n",p->num,p->bname,p->wname,p->press,p->sort,p->time,p->price);16
=========================================================================\n");}}//按圖書名查詢圖書信息voidbname_chaxun(structbook*head){a[50];intstructbookprintf("選擇您要查詢的圖書:p=head;flag=1;break;}}printf("有找到該圖書名的圖!\n");}else{
你所查詢的圖書信息如下\n");=========================================================================\n");**編圖名作者名出社類別出版時價格**\n");**%s%s%d**\n",p->num,p->bname,p->wname,p->press,p->sort,p->time,p->price);}}=========================================================================\n");}17
}//按作者名查詢圖書信息voidbook*head){a[50];intstructbookprintf("選擇您要查詢的圖書作者:p=head;flag=1;break;}}printf("有找到該圖書名的圖!\n");}else{
你所查詢的圖書信息如下\n");=========================================================================\n");**編圖名作者名出社類別出版時價格**\n");**%s%s%d**\n",p->num,p->bname,p->wname,p->press,p->sort,p->time,p->price);flag=1;}}=========================================================================\n");}}//按圖書類別查詢圖書信息18
void{a[50];intstructbookprintf("選擇您要查詢的圖書類別");p=head;if(strcmp(p->sort,a)==0){flag=1;break;}}printf("有找到該圖書名的圖!\n");}else{
你所查詢的圖書信息如下\n");=========================================================================\n");**編圖名作者名出社類別出版時價格**\n");if(strcmp(p->sort,a)==0){**%s%s%d**\n",p->num,p->bname,p->wname,p->press,p->sort,p->time,p->price);flag=1;}}=========================================================================\n");}}//按圖書出版時間查詢圖書信息voidbook*head){inta,flag=0;19
structbookprintf("選擇您要查詢的圖書出版時:getchar();p=head;if(p->time==a){flag=1;break;}}printf("有找到該圖書名的圖!\n");}else{
你所查詢的圖書信息如下\n");=========================================================================\n");**編圖名作者名出社類別出版時價格**\n");if(p->time==a){**%s%s%d**\n",p->num,p->bname,p->wname,p->press,p->sort,p->time,p->price);flag=1;}}=========================================================================\n");}}//修改圖書信息voidxiugai(structbook{inta,b;structbookprintf("輸入要修改的圖書編:20
p=head;if(p->num==a)break;}if(p==NULL){printf("有找到該編號的圖書!\n");getchar();}else{============================================================\n");**1-編號圖書名者名**\n");**出版社5-類別版時間**\n");**7-價格8-修改全部棄修改**\n");============================================================\n");printf("選擇你要修改的信息編號");getchar();switch(b){printf("輸入新編號:scanf("%d",&p->num);printf("改成功!\n");getchar();break;printf("輸入新圖書:printf("改成功!\n");break;printf("輸入新作者:printf("改成功!\n");break;printf("輸入新出版:21
作出放
gets(p->press);printf("改成功!\n");break;printf("輸入新類別:printf("改成功!\n");break;printf("輸入新出版時間:scanf("%d",&p->time);printf("改成功!\n");getchar();break;printf("輸入新價格:scanf("%f",&p->price);printf("改成功!\n");getchar();break;printf("輸入新圖書編號:scanf("%d",&p->num);printf("輸入新圖書名:scanf("%s",p->bname);getchar();printf("輸入新作者名:getchar();printf("輸入新出版社:scanf("%s",p->press);getchar();printf("輸入新類別:getchar();printf("輸入新出版時間:");scanf("%d",&p->time);getchar();printf("輸入新價格:scanf("%f",&p->price);getchar();printf("改成功!\n");getchar();break;22
break;default:printf("的輸入有誤!\n");break;}printf("否將修改后的信息保存到文件?(y/n)\n");getchar();switch(c){'n':break;fprint(head);printf("存成功!\n");getchar();break;}}}//圖書排序voidpaixu(structbook{inta;================================================================\n");**1-按書編號排序按出版時間排序**\n");**按圖書價格排序4-按圖書名排序**\n");**5-按者名排序取排序操作**\n");================================================================\n");printf("輸入您選擇的編:getchar();switch(a){break;break;23
break;break;bname_paixu(head);break;break;printf("的輸入有誤!\n");break;}}//按圖書編號排序voidbook{structbook*a[1000],*p,*p1,*temp;inti,k,index,n=0;p1=head;for(i=0;i<n;i++){}for(k=0;k<n-1;k++){if(a[i]->num<a[index]->num)}a[k]=temp;}printf("序成功!\n");printf("否顯示排序結果?(y/n)\n");scanf("%s",&b);24
getchar();switch(b){'n':break;================================================================\n");**編號圖書名作者名出社類別出時間價格**\n");for(i=0;i<n;i++){**%d%s%d}================================================================\n");break;printf("的輸入有誤!\n");break;}}//按出版時間排序voidtime_paixu(struct{structbook*a[1000],*p,*p1,*temp;inti,k,index,n=0;p1=head;for(i=0;i<n;i++){}for(k=0;k<n-1;k++){if(a[i]->time<a[index]->time)}a[k]=temp;25
}printf("序成功!\n");printf("否顯示排序結果?(y/n)\n");scanf("%s",&b);getchar();switch(b){'n':break;===============================================================\n");**編號圖書名作者名出社類別出時間價格**\n");for(i=0;i<n;i++){**%d%s%s%d}===============================================================\n");break;printf("的輸入有誤!\n");break;}}//按圖書價格排序voidprice_paixu(structbook{structbook*a[1000],*p,*p1,*temp;inti,k,index,n=0;p1=head;for(i=0;i<n;i++){}for(k=0;k<n-1;k++){if(a[i]->price<a[index]->price)26
}a[k]=temp;}printf("序成功!\n");printf("否顯示排序結果?(y/n)\n");scanf("%s",&b);get
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 湖南都市職業(yè)學院《現(xiàn)代建筑企業(yè)運營管理》2023-2024學年第二學期期末試卷
- 鹽城工學院《免疫學原理及技術》2023-2024學年第二學期期末試卷
- 浙江東方職業(yè)技術學院《影視后期特效設計》2023-2024學年第二學期期末試卷
- 洛陽科技職業(yè)學院《建筑工業(yè)化與裝配式建筑》2023-2024學年第二學期期末試卷
- 湖南汽車工程職業(yè)學院《中國當代文學(二)》2023-2024學年第二學期期末試卷
- 武漢設計工程學院《生理學》2023-2024學年第二學期期末試卷
- 陜西郵電職業(yè)技術學院《都市型現(xiàn)代農業(yè)概論》2023-2024學年第二學期期末試卷
- 山西大同大學《儀器分析(光譜)》2023-2024學年第二學期期末試卷
- 福建華南女子職業(yè)學院《案例分析》2023-2024學年第二學期期末試卷
- 貴州民族大學《工程訓練(Ⅱ)B》2023-2024學年第二學期期末試卷
- 2025屆高考語文復習:二元思辨類作文寫作指導+課件
- 報價單模板完
- 2021譯林版高中英語選擇性必修三課文翻譯
- 2022年華中科技大學博士研究生英語入學考試真題
- 《網(wǎng)店運營與管理》整本書電子教案全套教學教案
- 打印版 《固體物理教程》課后答案王矜奉
- CAD術語對照表
- 香港牛津新魔法Newmagic3AUnit4Mycalendar單元檢測試卷
- 中考《紅星照耀中國》各篇章練習題及答案(1-12)
- Q∕GDW 11612.43-2018 低壓電力線高速載波通信互聯(lián)互通技術規(guī)范 第4-3部分:應用層通信協(xié)議
- 自動化物料編碼規(guī)則
評論
0/150
提交評論