當前位置:首頁 » 編程語言 » 如何用c語言製作圖書館管理系統
擴展閱讀
webinf下怎麼引入js 2023-08-31 21:54:13
堡壘機怎麼打開web 2023-08-31 21:54:11

如何用c語言製作圖書館管理系統

發布時間: 2023-01-05 02:07:56

Ⅰ 如何用c語言編寫圖書館管理系統

為什麼一定要用C語言呢?
資料庫多不好做啊

Ⅱ 用c語言寫圖書館管理系統

你不覺得給的懸賞少了點么
新建一個下面的文件 講這個文件和下面的代碼放在一個目錄下 表示你的圖書資料庫信息
lib.txt

1001 1
1 0
c primier
1003 1
1 0
c primier
1002 2
1 0
c++ primier

代碼

#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>//定義bool類型
#include<string.h>
typedef struct book book;
struct book{
int bid;//書的id
int cid;//category id 所屬的書的類別id
char bname[30];
int state;//書的state 0 已借出 1代表還未借出
int stdid;//借書人id 如果未借出 則此項為0
};
//booklist
book lib[100];
int len=0;
//書的類別五類
int category[5]={0};
void init_lib()//講lib.txt存儲的圖書館信息讀入內存
{
FILE *fin=fopen("lib.txt","r");
if(!fin)
{
printf("openfile error!\n");
exit(1);
}
len=0;
while(!feof(fin))
{
fscanf(fin,"%d %d",&lib[len].bid,&lib[len].cid);
fscanf(fin,"%d %d",&lib[len].state,&lib[len].stdid);
fgetc(fin);
fgets(lib[len].bname,28,fin);
lib[len].bname[strlen(lib[len].bname)-1]='\0';//去除\n
category[lib[len].cid]++;
len++;
}
fclose(fin);

}
void libprint()//輸出圖書信息
{
int i;
for(i=0;i<len;i++)
{
printf("書名:%s\n編號:%d \n書目前的所屬人(0代表圖書館):%d \n同類別圖書共有:%d\n",lib[i].bname,lib[i].bid,lib[i].stdid,category[lib[i].cid]);
printf("-------------------------------------------------------------------------\n");
//printf("%d %d\n%d %d\n%s",lib[i].bid,lib[i].cid,lib[i].state,lib[i].stdid,lib[i].bname);
}
}
bool borrowbook(int bookid,int stdid)//借書
{
int i;
for(i=0;i<len;i++)
{
if(bookid==lib[i].bid&&lib[i].state==1)
{
lib[i].state=0;
category[lib[i].cid]--;
lib[i].stdid=stdid;
return 1;
}else
return 0;
}
return 0;
}
bool returnbook(int bookid,int stdid)//還書
{
int i=0;
for(i=0;i<len;i++)
{
if(bookid==lib[i].bid&&lib[i].state==0&&lib[i].stdid==stdid)
{
lib[i].state=1;
lib[i].stdid=0;
category[lib[i].cid]++;
return 1;
}
}
return 0;
}
void savelib()//將內存的數據寫入lib.txt存儲起來
{
FILE *fout=fopen("lib.txt","w");
if(!fout)
{
printf("寫入失敗!\n");
exit(0);
}

int i;
for(i=0;i<len;i++)
{
fprintf(fout,"%d %d\n%d %d\n%s\n",lib[i].bid,lib[i].cid,lib[i].state,lib[i].stdid,lib[i].bname);
}
fclose(fout);
printf("成功寫入資料庫文件!\n");

}
int main(void)
{
int choice,stdid,bookid;

init_lib();//數據讀入內存

while(1)
{
choice=0;
printf("圖書館管理系統\n");
printf("---------------\n");
printf("1-將每本書信息輸出\n");
printf("2-借書 \n");
printf("3-還書 \n");
printf("4-save \n");
printf("5-exit without save\n");
printf("---------------------------\n");
scanf("%d",&choice);
printf("---------------------------\n");
if(choice<1||choice>5)
{
printf("檢查你的輸入!(1,2,3,4,5)\n");
continue;
}
if(choice==1)
libprint();
if(choice==2)
{
printf("輸入你要借的書的id和你的studentid(以空格分隔):\n");
scanf("%d %d",&bookid,&stdid);
if(borrowbook(bookid,stdid))
printf("成功借出!\n");
else
printf("借出錯誤\n");
}
if(choice==3)
{
printf("輸入你要還的書的id和你的studentid(以空格分隔):\n");
scanf("%d %d",&bookid,&stdid);
if(returnbook(bookid,stdid))
printf("成功還書\n");
else
printf("還書錯誤\n");
}
if(choice==4)
{
savelib();
}
if(choice==5)
exit(0);

}
return 0;
}

Ⅲ 如果用C語言編寫一個圖書館管理系統,大概需要什麼樣的主函數求大體的編寫步驟

建議採用模塊化,自頂向低的編程思路
主函數只負責繪制菜單,根據用戶的選擇跳入對應功能。
然後各個功能有一個函數單獨編寫實現,調試,最後組裝完成。
如果你的系統需要實現添加、保存、修改、刪除、排序等功能,建議採用文件讀寫
可能會用到如下函數
strcmp(字元串比較函數,用於查找)
fprintf/fscanf/fopen/fclose(文件讀寫函數)
並且可能會用到結構體數組

如果您有需要,可以私信我,我可以幫您代寫。
謝謝

Ⅳ C語言程序設計的圖書管理系統

我們也開始做課程設計了呢~~~ 這是我同學做的:

#include
#include
#include

struct BOOK
{
int id,usr[10],total,store,days[10];
char name[31],author[21];
}books[100];
/*上面是結構體的定義,用於存放書籍及借書的信息。*/

void page_title(char *menu_item)
{
clrscr();
printf(">>> 圖 書 管 理 系 統 <<<\n\n- %s -\n\n",menu_item);
}
/*上面是列印頁眉的函數,同時通過參數menu_item,可以顯示當前的狀態。*/

void return_confirm(void)
{
printf("\n按任意鍵返回……\n");
getch();
}
/*上面是返回前請求確認的函數,以便在返回前觀察結果*/

int search_book(void)
{
int n,i;
printf("請輸入圖書序號:");
scanf("%d",&i);
for(n=0;n<100;n++)
{
if(books[n].id==i)
{
printf("書名:%s\n",books[n].name);
printf("作者:%s\n",books[n].author);
printf("存數:%d of ",books[n].store);
printf("%d\n",books[n].total);
return n;
}
}
printf("\n輸入錯誤或無效圖書序號.\n");
return -1;
}
/*上面的函數是在數組中找到圖書號匹配的記錄,顯示其信息並返
回數組下標,如果找不到相應記錄則提示錯誤並返回-1。*/

void book_out(void)
{
int n,s,l,d;
page_title("借閱圖書");
if((n=search_book())!=-1&&books[n].store>0)
{
printf("請輸入借書證序號:");
scanf("%d",&s);
printf("請輸入可借天數:");
scanf("%d",&d);
for(l=0;l<10;l++)
{
if(books[n].usr[l]==0)
{
books[n].usr[l]=s;
books[n].days[l]=d;
break;
}
}
books[n].store--;
}
if(n!=-1&&books[n].store==0) printf("此書已經全部借出.\n");
return_confirm();
}
/*上面是借書的函數,首先調用找書函數*/

void book_in(void)
{
int n,s,l;
page_title("歸還圖書");
if((n=search_book())!=-1&&books[n].store<books[n].total)
{
printf("借閱者圖書證列表:\n");
for(l=0;l<10;l++)
if (books[n].usr[l]!=0)
printf("[%d] - %d天\n",books[n].usr[l],books[n].days[l]);
printf("請輸入借書證序號:");
scanf("%d",&s);
for(l=0;l<10;l++)
{
if(books[n].usr[l]==s)
{
books[n].usr[l]=0;
books[n].days[l]=0;
break;
}
}
books[n].store++;
}
if(n!=-1&&books[n].store==books[n].total)
printf("全部入藏.\n");
return_confirm();
}

void book_add(void)
{
int n;
page_title("注冊新書");
for(n=0;n<100;n++)
if(books[n].id==0) break;
printf("序號:");
scanf("%d",&books[n].id);
printf("書名:");
scanf("%s",&books[n].name);
printf("作者:");
scanf("%s",&books[n].author);
printf("數量:");
scanf("%d",&books[n].total);
books[n].store=books[n].total;
return_confirm();
}
void book_del(void)
{
int n;
page_title("注銷舊書");
if((n=search_book())!=-1) books[n].id=0;
printf("該書已注銷.\n");
return_confirm();
}

void main(void)
{
menu: page_title("操作選單");
printf("請用數字鍵選擇操作\n\n");
printf("1 借閱圖書\n2 歸還圖書\n\n");
printf("3 注冊新書\n4 注銷舊書\n\n");
printf("\n0 退出\n");
switch(getch())
{
case '1' : book_out();break;
case '2' : book_in();break;
case '3' : book_add();break;
case '4' : book_del();break;
case '0' : exit(0);
}
goto menu;
}
{
int n;
page_title("廣?症慕");
if((n=search_book())!=-1) books[n].id=0;
printf("乎慕廝廣?.\n");
return_confirm();
}

void main(void)
{
menu: page_title("荷恬僉汽");
printf("萩喘方忖囚僉夲荷恬\n\n");
printf("1 処堋夕慕\n2 拷珊夕慕\n\n");
printf("3 廣過仟慕\n4 廣?症慕\n\n");
printf("\n0 曜竃\n");
switch(getch())
{
case '1' : book_out();break;
case '2' : book_in();break;
case '3' : book_add();break;
case '4' : book_del();break;
case '0' : exit(0);
}
goto menu;
}

Ⅳ 用C語言寫個圖書館系統

下面可以參考參考!

完整的C語言圖書管理系統

#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include "graphics.h"
#include "math.h"
#define m 1
struct data
{ int year;
int month;
int day;
};

struct ReaderNode
{
char num[20];
struct data bro;
struct data back;
};

struct BookNode
{
char title[15];
char writer[15];
int currentnum;
int totalnum;
char brief[30];
struct ReaderNode reader[20];
};

struct TreeNode
{
int n;
struct TreeNode *prt;
int key[2*m];
struct BookNode *rec[2*m];
struct TreeNode *link[2*m+1];

};

struct BookNode *InputNode();
struct TreeNode *mbsearch(struct TreeNode *bth,int x,int *k,int *flag);
struct TreeNode *mbinsert(struct TreeNode *bth);
struct TreeNode *mbdel(struct TreeNode *bth);
void OutputNode(struct TreeNode *bth);
void borrow(struct TreeNode *bth);
void payback(struct TreeNode *bth);
char menu(void);
struct TreeNode *mbsearch(struct TreeNode *bth,int x,int *k,int *flag)
{
struct TreeNode *p,*q;
p=bth; *flag=0; q=p;
while( (p!=NULL) && (*flag==0) )
{
*k=1;q=p;
while( (*k < q->n) && ( q->key[*k-1] < x) ) *k=*k+1;
if( q->key[*k-1]==x) *flag=1;
else if( ( *k==q->n ) && ( q->key[*k-1] < x) ) {p=q->link[*k];p->prt=q;}
else { p=q->link[*k-1]; p->prt=q;*k=*k-1;}
}
return(q);
}

struct TreeNode *mbinsert(struct TreeNode *bth)
{
int flag,j,k,t;
int y,x,z;
struct TreeNode *p,*q,*u,*s;
struct BookNode *r,*l;
clrscr();
printf("\n\tPlease input the book you want to insert: ");
scanf("%d",&x);
q=mbsearch(bth,x,&k,&flag);
if(flag==1)
{

printf("\n\tHas %d this kind of book,do you want to add another?(y/n)\n",(q->rec[k-1])->totalnum);
z=getch();
if(z=='y'||z=='Y')
{
(q->rec[k-1])->totalnum++; (q->rec[k-1])->currentnum++;
printf("\n\tNow total has %d this kind of book,",(q->rec[k-1])->totalnum);
printf("\n\tand current has %d in the library.",(q->rec[k-1])->currentnum);
}
return(bth);
}
r=InputNode(bth);
if(bth==NULL)
{
bth=p=(struct TreeNode *)malloc(sizeof(struct TreeNode));
p->n=1; p->key[0]=x; p->rec[0]=r;p->prt=NULL;
for(j=1;j<=2*m+1;j++) p->link[j-1]=NULL;
return(p);
}

p=NULL; t=0;
while(t==0)
{
if(k==q->n) {y=x;l=r;u=p;}
else
{
y=q->key[q->n-1]; l=q->rec[q->n-1];u=q->link[q->n];
for(j=(q->n)-1; j>=k+1; j--)
{
q->key[j]=q->key[j-1];q->rec[j]=q->rec[j-1];q->link[j+1]=q->link[j];
}
q->key[k]=x;q->rec[k]=r;q->link[k+1]=p;
if(p!=NULL) p->prt=q;
}

if(q->n<2*m)
{
q->n=(q->n)+1;
t=1;
q->key[(q->n)-1]=y; q->rec[(q->n)-1]=l; q->link[q->n]=u;
if(u!=NULL) u->prt=q;
}
else
{
p=(struct TreeNode *)malloc(sizeof(struct TreeNode));
p->n=m; q->n=m; p->prt=q->prt;
x=q->key[m];r=q->rec[m];
for(j=1;j<=m-1;j++)
{
p->key[j-1]=q->key[m+j];p->rec[j-1]=q->rec[m+j];p->link[j-1]=q->link[m+j];
if(q->link[m+j]!=NULL) (q->link[m+j])->prt=p;

}

p->link[m-1]=q->link[2*m];
p->link[m]=u;
p->key[m-1]=y;
p->rec[m-1]=l;

if(u!=NULL) u->prt=p;
for(j=m+2;j<=2*m+1;j++)
{
q->link[j-1]=NULL;p->link[j-1]=NULL;
}

if(q->prt==NULL)
{
s=(struct TreeNode *)malloc(sizeof(struct TreeNode));
s->key[0]=x; s->rec[0]=r;
s->link[0]=q; s->link[1]=p;
s->n=1; s->prt=NULL; q->prt=s; p->prt=s;
for(j=3;j<=2*m+1;j++) s->link[j-1]=NULL;
bth=s; t=1;
}
else
{
q=q->prt; k=1;
while((k<=q->n)&&(q->key[k-1]<x)) k=k+1;
k=k-1;
}
}
}
return(bth);
}
struct TreeNode *mbdel(struct TreeNode *bth)
{
int flag,j,k,t;
int x,y;
struct TreeNode *u,*s,*p,*q;
struct BookNode *r,*l;
clrscr();
printf("\n\tPlease input the book you want to delete: ");
scanf("%d",&x);
q=mbsearch(bth,x,&k,&flag);
if(flag==0) { printf("\n\tThe book is not exist!\n"); return(bth);}
p=q->link[k];
if(p!=NULL)
{
while(p->link[0]!=NULL) p=p->link[0];
q->key[k-1]=p->key[0];
q->rec[k-1]=p->rec[0];
k=1;q=p;
}

for(j=k;j<=q->n-1;j++)
{
q->key[j-1]=q->key[j];
q->rec[j-1]=q->rec[j];
}
q->n=q->n-1;

while ((q!=bth)&&(q->n<m))
{
p=q->prt;j=1;
while(p->link[j-1]!=q) j=j+1;
if((j<=p->n)&&((p->link[j])->n>m))
{
s=p->link[j];
y=s->key[0];
l=s->rec[0];
u=s->link[0];
for(k=1;k<=s->n-1;k++)
{
s->key[k-1]=s->key[k];
s->rec[k-1]=s->rec[k];
s->link[k-1]=s->link[k];
}
s->link[s->n-1]=s->link[s->n];
s->link[s->n]=NULL;
s->n=s->n-1; q->n=q->n+1;
q->key[q->n-1]=p->key[j-1];
q->rec[q->n-1]=p->rec[j-1];
q->link[q->n]=u;
p->key[j-1]=y;
p->rec[j-1]=l;
if(u!=NULL) u->prt=q;
}
else if((j>1)&&((p->link[j-2])->n>m))
{
s=p->link[j-2];
q->n=q->n+1;
q->link[q->n]=q->link[q->n-1];

for(k=q->n-1;k>=1;k--)
{
q->key[k]=q->key[k-1];
q->rec[k]=q->rec[k-1];
q->link[k]=q->link[k-1];
}
q->key[0]=p->key[j-2];
q->rec[0]=p->rec[j-2];
u=s->link[s->n];
q->link[0]=u;
if(u!=NULL) u->prt=q;
p->key[j-2]=s->key[s->n-1];
p->rec[j-2]=s->rec[s->n-1];
s->link[s->n]=NULL;
s->n=s->n-1;
}

else
{
if(j==p->n+1)
{ q=p->link[j-2]; s=p->link[j-1]; j=j-1;}
else s=p->link[j];
q->key[q->n]=p->key[j-1];
q->rec[q->n]=p->rec[j-1];
t=q->n+1;
for(k=1;k<=s->n;k++)
{ q->key[t+k-1]=s->key[k-1];
q->rec[t+k-1]=s->rec[k-1];
u=s->link[k-1];
q->link[t+k-1]=u;
if(u!=NULL) u->prt=q;
}
u=s->link[s->n]; q->link[t+s->n]=u;
if(u!=NULL) u->prt=q;
q->n=2*m;
free(s);
for(k=j;k<=p->n-1;k++)
{
p->key[k-1]=p->key[k];
p->rec[k-1]=p->rec[k];
p->link[k]=p->link[k+1];
}
p->n=p->n-1; s=q; q=p;
}
}
if((q==bth)&&(q->n==0))
{ free(bth); bth=s; bth->prt=NULL;
if(s->n==0) {bth=NULL; free(s); }
}
printf("\n\tThe book has been delete !");
return(bth);
}
struct BookNode *InputNode()
{
struct BookNode *p;
int i;
p=(struct BookNode *)malloc(sizeof(struct BookNode));
clrscr();
fflush(stdin);
printf("\n\tInput the title: ");
gets(p->title);
printf("\n\tInput the writer: ");
gets(p->writer);
printf("\n\tInput the book current amount: ");
scanf("%d",&p->currentnum);
printf("\n\tInput the book total amount: ");
scanf("%d",&p->totalnum);
fflush(stdin);
printf("\n\tInput the book brief instruction: ");
gets(p->brief);
for(i=0;i<20;i++)
(p->reader[i]).num[0]='\0';
return(p);
}
void OutputNode(struct TreeNode *bth)
{
struct TreeNode *q;
struct BookNode *p;
int k;
int x;
int flag;
clrscr();
printf("\n\tPlease input the book you want to search: ");
scanf("%d",&x);
q=mbsearch(bth,x,&k,&flag);
if(flag==1)
{
p=q->rec[k-1];
printf("\n\tTitle: %s",p->title);
printf("\n\tWriter: %s",p->writer);
printf("\n\tCurrentAmount: %d",p->currentnum);
printf("\n\tTotalAmount: %d",p->totalnum);
printf("\n\tBriefIntroction: %s\n",p->brief);
}
else printf("\n\tThis book is not exist!");
}
void borrow(struct TreeNode *bth)
{
struct TreeNode *q;
struct BookNode *p;
struct ReaderNode *r;
int i,k, x, flag,t;
clrscr();
printf("\n\tPlease input the book you want to borrow: ");
scanf("%d",&x);
q=mbsearch(bth,x,&k,&flag);
if(flag==1)
{
p=q->rec[k-1];
printf("\n\tDo you want this book ?(y/n)");
printf("\n\tTitle: %s",p->title);
printf("\n\tWriter: %s",p->writer);
printf("\n\tCurrentAmount: %d",p->currentnum);
printf("\n\tTotalAmount: %d",p->totalnum);
printf("\n\tBriefIntroction: %s",p->brief);
t=getch();
if(t=='y'||t=='Y')
{
if( (p->currentnum)==0) printf("\n\tSorry,this book has all borrow out...");
else
{
clrscr();
for(i=0;i<20;i++) if( (p->reader[i]).num[0]=='\0') break;
printf("\n\tPlease input your certificate number: ");
scanf("%s",(p->reader[i]).num);
printf("\n\tPlease input the borrow data: ");
printf("\n\tYear: ");
scanf("%d",&((p->reader[i]).bro.year));
printf("\tMonth: ");
scanf("%d",&((p->reader[i]).bro.month));
printf("\tDay: ");
scanf("%d",&((p->reader[i]).bro.day));

printf("\n\tPlease input the payback data: ");
printf("\n\tYear: ");
scanf("%d",&((p->reader[i]).back.year));
printf("\tMonth: ");
scanf("%d",&((p->reader[i]).back.month));
printf("\tDay: ");
scanf("%d",&((p->reader[i]).back.day));

p->currentnum--;
printf("\n\tYou have borrow the book.");}
}

}
else printf("\n\tThis book is not exist!");
}
void payback(struct TreeNode *bth)
{
struct TreeNode *q;
struct BookNode *p;
int i,k, x, flag,t,j;
int year,month,day,d;
float pay;
char temp[20];
clrscr();
printf("\n\tPlease input the book you want to payback: ");
scanf("%d",&x);
q=mbsearch(bth,x,&k,&flag);
if(flag==1)
{
p=q->rec[k-1];
printf("\n\tDo you want to payback this book ?(y/n)");
printf("\n\tTitle: %s",p->title);
printf("\n\tWriter: %s",p->writer);
printf("\n\tCurrentAmount: %d",p->currentnum);
printf("\n\tTotalAmount: %d",p->totalnum);
printf("\n\tBriefIntroction: %s",p->brief);
t=getch();
if(t=='y'||t=='Y')
{
if( (p->currentnum) >=(p->totalnum) )
printf("\n\tYou want to offer a more book ??\n");
else
{
clrscr();
printf("\n\tPlease input your certificate number: ");
scanf("%s",temp);
j=0;
for(i=0;i<20;i++)
{
if(! (strcmp(temp,(p->reader[i]).num))) {j=1;break;}
}
if(j==0) {printf("\n\tYou haven't borrow this book.");return;}
printf("\n\tToday is:");
printf("\n\tYear: ");
scanf("%d",&year);
printf("\tMonth: ");
scanf("%d",&month);
printf("\tDay: ");
scanf("%d",&day);

d=0;
if(year<(p->reader[i]).back.year) d=1;
if(year<=(p->reader[i]).back.year && month<(p->reader[i]).back.month) d=1;
if(year<=(p->reader[i]).back.year && month<=(p->reader[i]).back.month && day<(p->reader[i]).back.day) d=1;
if(d==0)
{
clrscr();
pay=(year-(p->reader[i]).back.year)*365+(month-(p->reader[i]).back.month)*30+(day-(p->reader[i]).back.day);
printf("\n\tYou borrow this book is in %d-%d-%d",(p->reader[i]).bro.year,(p->reader[i]).bro.month,(p->reader[i]).bro.day);
printf("\n\tYou should pay it back in %d-%d-%d",(p->reader[i]).back.year,(p->reader[i]).back.month,(p->reader[i]).back.day);
printf("\n\tToday is %d-%d-%d",year,month,day);
printf("\n\n\tSo you have go out the payback day");
printf("\n\tYou have to pay %2.1f Yuan.",0.1*pay);
}
(p->reader[i]).num[0]='\0';
p->currentnum++;
printf("\n\tYou have payback the book.");
}
}

}
else printf("\n\tYou want to payback an inexistence book ???");

}
donghua()
{int graphdriver=VGA;
int graphmode=VGAHI;
int i,j;
registerbgidriver(EGAVGA_driver);
initgraph(&graphdriver,&graphmode,"");
clrscr();

for(i=0;i<=150;i+=5)
{setcolor(i);
textbackground(RED);
settextstyle(0,0,2);
outtextxy(100,i+140,"Liberary management System");
delay(10000000);
clrscr();
}
setcolor(RED);
outtextxy(50,200,"Loading");
delay(100000000000);
outtextxy(50,200,"Loading.");
delay(100000000000);
outtextxy(50,200,"Loading..");
delay(100000000000);
outtextxy(50,200,"Loading...");
delay(100000000000);
outtextxy(50,200,"Loading....");
delay(100000000000);
outtextxy(50,200,"Loading.....");
delay(100000000000);
outtextxy(50,200,"Loading......");
delay(100000000000);
outtextxy(50,200,"Loading.......");
delay(100000000000);
outtextxy(50,200,"Loading........");
delay(100000000000);
outtextxy(50,200,"Loading.........");
delay(100000000000);
outtextxy(50,200,"Loading..........");
delay(100000000000);
outtextxy(50,200,"Loading...........");
outtextxy(50,200,"Loading............");
delay(100000000000);
for(i=0;i<=10;i++)
delay(100000000000);
clrscr();

}
char menu(void)
{
clrscr();
window(1,1,80,25);
textmode(MONO);
textbackground(BLACK);
textcolor(5);
printf("\n\t ****************************************************");
printf("\n\t ***** Welcome to Liberary management System *****");
printf("\n\t ****************************************************");
printf("\n\t ****************************************************");
printf("\n\t *1.Add a book *");
printf("\n\t ****************************************************");
printf("\n\t *2.Delete a book *");
printf("\n\t ****************************************************");
printf("\n\t *3.Search a book *");
printf("\n\t ****************************************************");
printf("\n\t *4.Borrow a book *");
printf("\n\t ****************************************************");
printf("\n\t *5.Payback a book *");
printf("\n\t ****************************************************");
printf("\n\t *0.exit *");
printf("\n\t ****************************************************");
printf("\n\t please select: ");
return getch();
}
bofangdonghua()
{int graphdriver=VGA;
int graphmode=VGAHI;
int i,j;
char c;
registerbgidriver(EGAVGA_driver);
initgraph(&graphdriver,&graphmode,"");
/*************shi fou bo fang dong hua?**************/
printf:{setcolor(RED);
settextstyle(3,0,5);
outtextxy(100,30,"bo fang dong hua?");
outtextxy(150,80,"Yes");
outtextxy(300,80,"No");
c=getch();
if(c=='Y'||c=='y')
{donghua();
menu();
}
else
if(c=='N'||c=='n')
menu();
else
{setcolor(GREEN);
settextstyle(3,0,8);
outtextxy(200,240,"Error!");
delay(10000000000);
clrscr();
goto printf;
}
}
/**************************************/

}

void main()
{
char c,t;
int x;
int k,flag,p=1;
struct TreeNode *bth=NULL;

bofangdonghua();

while(1)
{
c=menu();
putch(c);
getch();
switch(c)
{
case '1': bth=mbinsert(bth);

break;

case '2': bth=mbdel(bth);

break;

case '3': OutputNode(bth);
break;

case '4': borrow(bth);
break;

case '5': payback(bth);
break;

case '0': clrscr();
printf("\n\tDo you want to return ?(y/n)");
t=getch();
if(t=='y'||t=='Y') exit(0);
break;
defult :break;
}
printf("\n\tPress any key to the main menu....");
getch();
}
}

Ⅵ 如何使用C語言編寫圖書管理系統

圖書管理系統是運行於Windows系統下的應用軟體,主要用於對圖書館中的圖書信息進行增、刪、改、查等操作,並且還可對使用該系統的用戶進行登錄名和密碼的管理等。系統給用戶提供了一個簡單的人機界面,使用戶可以根據提示輸入操作項,調用系統提供的管理功能。
所需功能類似於學生成績管理系統,界面可參考附錄C。用戶分為管理員和一般人員兩大類。
功能需求描述如下。
①用戶登錄:根據用戶輸入的用戶名和密碼判斷是否允許該用戶使用本系統,並且當用戶登錄後根據用戶許可權判斷用戶可以使用哪些功能。學生只有瀏覽等許可權而不能進行實質性改動。
②提供系統主控平台:系統主控平台也應根據用戶許可權不同而有所區別,只列出在用戶許可權范圍內的功能供用戶選擇。系統主控平台包括輸入功能選項、調用相應程序兩大需求。教師和學生對應的系統主控平台是不同的。所能進行的操作也不相同。
③創建圖書信息文件:用戶根據提示輸入圖書編號、圖書分類號、書名、作者姓名、出版社名、出版年月、定價、存庫數量和借閱和上架情況等等信息存儲在系統磁碟的文件中。以便進行管理、查找和備份。
④增加圖書信息:可在原有圖書信息文件的基礎上增加新的圖書信息記錄並繼續保存至磁碟,並且將增加後的文件存儲狀況顯示給用戶。
⑤刪除圖書信息:提示用戶輸入要進行刪除操作的圖書編號,如果在文件中有該信息存在,則將該書號所對應的記錄刪除。並選擇是否繼續進行刪除操作。
⑥修改圖書信息:提示用戶輸入要進行修改操作的書號,如果在文件中有該息存在,則將提示用戶輸入該書號對應的要修改的選項,結果存儲於文件。該部分需求也需要提示用戶選擇是否繼續進行修改操作。
⑦查詢圖書信息:提供按書號或書名等查詢。在該功能中,也需提示用戶是否需要繼續查再繼續查找,則返回主界面。
⑧一般用戶查詢個人的借閱情況並按日期進行排序:。
⑨管理員和一般用戶管理:管理員對用戶的管理也需要進行用戶的創建、增加、刪除、瀏覽。管理員創建的用戶存儲在名為yonghu的磁碟文件中,每當有用戶登錄系統時,會根據該文件中的用戶名和密碼進行核實判斷,用戶才能夠順利登錄。管理員還具有用戶的功能。增加的用戶及密碼、許可權等也被繼續存儲在yonghu文件中。當某些用一用該系統時,還可以進行刪除操作,並且管理員具有修改用戶許可權的功能,一般用戶和管理員對於系統的許可權是不一樣的。

Ⅶ 看不太明白 怎麼用C語言編寫圖書館管理系統呢

通過c語言中的鏈表記錄圖書的信息、修改圖書的信息、刪除圖書的信息、保存圖書的信息、輸出圖書的信息啊、載入圖書信息,記錄,修改,刪除很簡單解決,保存的話,就用文件的輸入輸出就行了,同理就是載入信息,也是用文件的輸入輸出就行了。然後這些各個功能就單獨作為一個函數,然後通過主函數去調用,就行了。

Ⅷ C語言圖書管理信息系統

借書的限制:教師180天,借15本;學生120天,借10本

圖書的信息:書的編號號,書名,作者,書的種類,書的總量以及書的剩餘量

學生/教師信息:學號/工號(4位數字字元),姓名,借書日期,還書日期(以此判定是否超出有效期)

(一)、查詢:(無條件或有條件指按所有欄位查詢)

一、單鏈表上實現圖書信息管理

利用鏈表結構實現圖書存儲

二、二叉排序樹或平衡樹上實現圖書信息管理

利用二叉排序樹或平衡樹實現圖書的存儲

三、B_樹的操作(手工題)

插入、刪除操作:

從空的3階B_樹開始,依次插入20,30,50,52,60,68,70,10,80,90,40,75。畫出建樹過程,然後分別畫出刪除50,60,10,75,20的B_樹狀態。

1.課程設計的題目內容要求

2.數據結構的設計思想和任務的總體結構

鏈接:https://pan..com/s/11BBC4ec7x3l62u83lJeGpw

提取碼:1234

Ⅸ 怎樣用C語言製作圖書館管理系統

這個是自己寫的
注釋很清楚地

有什麼不清楚的問我

#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>

struct books_list
{

char author[20]; /*作者名*/
char bookname[20]; /*書名*/
char publisher[20]; /*出版單位*/
char pbtime[15]; /*出版時間*/
char loginnum[10]; /*登陸號*/
float price; /*價格*/
char classfy[10]; /*分類號*/
struct books_list * next; /*鏈表的指針域*/
};

struct books_list * Create_Books_Doc(); /*新建鏈表*/
void InsertDoc(struct books_list * head); /*插入*/
void DeleteDoc(struct books_list * head , int num);/*刪除*/
void Print_Book_Doc(struct books_list * head);/*瀏覽*/
void search_book(struct books_list * head); /*查詢*/
void info_change(struct books_list * head);/*修改*/
void save(struct books_list * head);/*保存數據至文件*/

/*新建鏈表頭節點*/
struct books_list * Create_Books_Doc()
{
struct books_list * head;
head=(struct books_list *)malloc(sizeof(struct books_list)); /*分配頭節點空間*/
head->next=NULL; /*頭節點指針域初始化,定為空*/
return head;
}

/*保存數據至文件*/
void save(struct books_list * head)
{
struct books_list *p;
FILE *fp;
p=head;
fp=fopen("data.txt","w+"); /*以寫方式新建並打開 data.txt文件*/
fprintf(fp,"┏━━━┳━━━━━┳━━━━━┳━━━━━┳━━━━━━┳━━━┳━━━━┓\n"); /*向文件輸出表格*/
fprintf(fp,"┃登錄號┃ 書 名 ┃ 作 者┃ 出版單位 ┃ 出版時間 ┃分類號┃ 價格 ┃\n");
fprintf(fp,"┣━━━╋━━━━━╋━━━━━╋━━━━━╋━━━━━━╋━━━╋━━━━┫\n");
/*指針從頭節點開始移動,遍歷至尾結點,依次輸出圖書信息*/
while(p->next!= NULL)
{
p=p->next;
fprintf(fp,"┃%-6.6s┃%-10.10s┃%-10.10s┃%-10.10s┃%-12.12s┃%-6.6s┃%.2f ┃\n",p->loginnum,p->bookname,p->author,p->publisher,p->pbtime,p->classfy,p->price);
}
fprintf(fp,"┗━━━┻━━━━━┻━━━━━┻━━━━━┻━━━━━━┻━━━┻━━━━┛\n");
fclose(fp);
printf(" 已將圖書數據保存到 data.txt 文件\n");
}

/*插入*/
void InsertDoc(struct books_list *head)
{
/*定義結構體指針變數 s指向開辟的新結點首地址 p為中間變數*/
struct books_list *s, *p;
char flag='Y'; /*定義flag,方便用戶選擇重復輸入*/
p=head;
/*遍歷到尾結點,p指向尾結點*/
while(p->next!= NULL)
{
p=p->next;
}
/*開辟新空間,存入數據,添加進鏈表*/
while(flag=='Y'||flag=='y')
{
s=(struct books_list *)malloc(sizeof(struct books_list));
printf("\n 請輸入圖書登陸號:");
fflush(stdin);
scanf("%s",s->loginnum);
printf("\n 請輸入圖書書名:");
fflush(stdin);
scanf("%s",s->bookname);
printf("\n 請輸入圖書作者名:");
fflush(stdin);
scanf("%s",s->author);
printf("\n 請輸入圖書出版社:");
fflush(stdin);
scanf("%s",s->publisher);
printf("\n 請輸入圖書出版時間:");
fflush(stdin);
scanf("%s",s->pbtime);
printf("\n 請輸入圖書分類號:");
fflush(stdin);
scanf("%s",s->classfy);
printf("\n 請輸入圖書價格:");
fflush(stdin);
scanf("%f",&s->price);
printf("\n");
p->next=s; /*將新增加的節點添加進鏈表*/
p=s; /*p指向尾節點,向後移*/
s->next=NULL;
printf(" ━━━━ 添加成功!━━━━");
printf("\n 繼續添加?(Y/N):");
fflush(stdin);
scanf("%c",&flag);
printf("\n");
if(flag=='N'||flag=='n')
{break;}
else if(flag=='Y'||flag=='y')
{continue;}
}
save(head); /*保存數據至文件*/
return;
}

/*查詢操作*/

void search_book(struct books_list *head)
{
struct books_list * p;
char temp[20];
p=head;
if(head==NULL || head->next==NULL) /*判斷資料庫是否為空*/
{
printf(" ━━━━ 圖書庫為空!━━━━\n");
}
else
{
printf("請輸入您要查找的書名: ");
fflush(stdin);
scanf("%s",temp);
/*指針從頭節點開始移動,遍歷至尾結點,查找書目信息*/
while(p->next!= NULL)
{
p=p->next;
if(strcmp(p->bookname,temp)==0)
{
printf("\n圖書已找到!\n");
printf("\n");
printf("登錄號: %s\t\n",p->loginnum);
printf("書名: %s\t\n",p->bookname);
printf("作者名: %s\t\n",p->author);
printf("出版單位: %s\t\n",p->publisher);
printf("出版時間: %s\t\n",p->pbtime);
printf("分類號: %s\t\n",p->classfy);
printf("價格: %.2f\t\n",p->price);
}
if(p->next==NULL)
{
printf("\n查詢完畢!\n");
}
}
}
return;
}

/*瀏覽操作*/

void Print_Book_Doc(struct books_list * head)
{
struct books_list * p;
if(head==NULL || head->next==NULL) /*判斷資料庫是否為空*/
{
printf("\n ━━━━ 沒有圖書記錄! ━━━━\n\n");
return;
}
p=head;
printf("┏━━━┳━━━━━┳━━━━━┳━━━━━┳━━━━━━┳━━━┳━━━━┓\n");
printf("┃登錄號┃ 書 名 ┃ 作 者┃ 出版單位 ┃ 出版時間 ┃分類號┃ 價格 ┃\n");
printf("┣━━━╋━━━━━╋━━━━━╋━━━━━╋━━━━━━╋━━━╋━━━━┫\n");
/*指針從頭節點開始移動,遍歷至尾結點,依次輸出圖書信息*/
while(p->next!= NULL)
{
p=p->next;
printf("┃%-6.6s┃%-10.10s┃%-10.10s┃%-10.10s┃%-12.12s┃%-6.6s┃%.2f ┃\n",p->loginnum,p->bookname,p->author,p->publisher,p->pbtime,p->classfy,p->price); /*循環輸出表格*/
}
printf("┗━━━┻━━━━━┻━━━━━┻━━━━━┻━━━━━━┻━━━┻━━━━┛\n");
printf("\n");
}

/*修改操作*/
void info_change(struct books_list * head)
{
struct books_list * p;
int panan=0; /*此變數用於判斷是否找到書目*/
char temp[20];
p=head;
printf("請輸入要修改的書名:");
scanf("%s",temp);
while(p->next!= NULL)
{
p=p->next;
if(strcmp(p->bookname,temp)==0)
{
printf("\n 請輸入圖書登陸卡號:");
fflush(stdin);
scanf("%s",p->loginnum);
printf("\n 請輸入圖書書名:");
fflush(stdin);
scanf("%s",p->bookname);
printf("\n 請輸入圖書作者名:");
fflush(stdin);
scanf("%s",p->author);
printf("\n 請輸入圖書出版社:");
fflush(stdin);
scanf("%s",p->publisher);
printf("\n 請輸入圖書出版時間:");
fflush(stdin);
scanf("%s",p->pbtime);
printf("\n 請輸入圖書分類號:");
fflush(stdin);
scanf("%s",p->classfy);
printf("\n 請輸入圖書價格:");
fflush(stdin);
scanf("%f",&p->price);
printf("\n");
panan=1;
}
}
if(panan==0)
{
printf("\n ━━━━ 沒有圖書記錄! ━━━━\n\n");
}
return;
}

/*刪除操作*/
void DeleteDoc(struct books_list * head)
{
struct books_list *s,*p; /*s為中間變數,p為遍歷時使用的指針*/
char temp[20];
int panan; /*此變數用於判斷是否找到了書目*/
panan=0;
p=s=head;
printf(" [請輸入您要刪除的書名]:");
scanf("%s",temp);
/*遍歷到尾結點*/
while(p!= NULL)
{
if(strcmp(p->bookname,temp)==0)
{
panan++;
break;
}
p=p->next;
}
if(panan==1)
{
for(;s->next!=p;) /*找到所需刪除卡號結點的上一個結點*/
{
s=s->next;
}
s->next=p->next; /*將後一節點地址賦值給前一節點的指針域*/
free(p);
printf("\n ━━━━ 刪除成功! ━━━━\n");
}
else /*未找到相應書目*/
{
printf(" 您輸入的書目不存在,請確認後輸入!\n");
}
return;
}

int main(void)
{
struct books_list * head;
char choice;
head=NULL;
for(;;) /*實現反復輸入選擇*/
{
printf(" ┏━┓━━━━━━━━━━━━━━━━━━━┏━┓\n");
printf(" ┃ ┃ socat 圖書管理系統 ┃ ┃\n");
printf(" ┃ ┗━━━━━━━━━━━━━━━━━━━┛ ┃\n");
printf(" ┃ ●[1]圖書信息錄入 ┃\n");
printf(" ┃ ┃\n");
printf(" ┃ ●[2]圖書信息瀏覽 ┃\n");
printf(" ┃ ┃\n");
printf(" ┃ ●[3]圖書信息查詢 ┃\n");
printf(" ┃ ┃\n");
printf(" ┃ ●[4]圖書信息修改 ┃\n");
printf(" ┃ ┃\n");
printf(" ┃ ●[5]圖書信息刪除 ┃\n");
printf(" ┃ ┃\n");
printf(" ┃ ●[6]退出系統 ┃\n");
printf(" ┗━━━━━━━━━━━━━━━━━━━━━━━┛\n");
printf(" 請選擇:");
fflush(stdin);
scanf("%c",&choice);
if(choice=='1')
{
if(head==NULL)
{
head=Create_Books_Doc();
}
InsertDoc(head);

}
else if(choice=='2')
{
Print_Book_Doc(head);
}
else if(choice=='3')
{
search_book(head);
}
else if(choice=='4')
{
info_change(head);
}
else if(choice=='5')
{
DeleteDoc(head);
}
else if(choice=='6')
{
printf("\n");
printf(" ━━━━━━━━ 感謝使用圖書管理系統 ━━━━━━━━\n");
break;
}
else
{
printf(" ━━━━ 輸入錯誤,請重新輸入!━━━━");
break;
}
}
return 0;
}

Ⅹ 如何用 C語言做 圖書管理系統(要求:不能用鏈表做)

網上很多的,無非就是結構體,然後賦值問題,指針,主要用這兩個多