广告
返回顶部
首页 > 资讯 > 后端开发 > 其他教程 >C语言大作业之图书管理系统的实现详程
  • 863
分享到

C语言大作业之图书管理系统的实现详程

2024-04-02 19:04:59 863人浏览 薄情痞子
摘要

目录主要内容概要设计项目源码结构体登录界面函数选择界面函数操作界面函数添加函数查找函数删除函数借书管理函数信息储存函数还书函数修改函数添加借书函数查找借书函数借书管理函数主函数总结序

时间在流去,我们在长大。

嗨,这里是狐狸~~

今天是2022年的一月四日了,元旦小长假也过去了,新年新气象,新年新目标,我们要向前看,不要执意过去了,感谢过去,把握现在,展望未来,这是我们现在应该做的。好了,废话不多说,今天我们分享一个系统,确实也有许久没有分享过系统了,今天就给大家详细讲一下这个图书管理系统吧。

主要内容

        开发一个图书信息管理系统,图书信息包括:图书编号、书名、作者、出版社、类别、出版时间、价格等基本信息(也可以根据自己情况进行扩充,比如是否借出、库存量等)。使之能提供以下基本功能:

(1)图书信息录入功能(图书信息用文件保存)--输入

(2)图书信息浏览功能--输出

(3)查询功能(至少一种查询方式)、排序功能(至少一种排序方式):

            ①按书名查询

            ②按作者名查询 按照价钱排序 按出版时间排序等等

(4)图书信息的删除与修改

          扩展功能:可以按照自己的程度进行扩展。比如

                          (1)简单的权限处理

                          (2)报表打印功能

                          (3)甚至根据自己情况,可以加上学生信息,并扩充为图书借阅系统。

                          (4)模糊查询

                          (5)综合查询

                          (6)统计功能 比如统计处某一类别的图书信息 或 筛选出小于指定数量库存的图书信息等等。

概要设计

1 图书录入可以录入图书名,作者,出版社,出版日期,价格!录入图书编号时函数就会判断此        编 号是否存在,若存在不能成功录入!

2 图书浏览可以浏览全部图书!

3 图书查询提供按图书编号模糊查询,按图书名关键字查询,按图书编号精确查询,按图书名精确      查询!模糊查询和关键字查询事通过比价字符串的相似度而实现的!

4 修改删除图书可以通过图书查询来查询操作的图书编号,通过编号操作!函数会提示用户是否调      用图书查询来找到自己想要操作的图书的编号。如果某一本图书已经被借阅那么用户就不能删        除 该图书!

5 借阅图书通过学号和图书编号进行借阅!如果该学号是第一次借阅那么会提示用户输入自己的姓      名,并存入student.txt,方便以后借阅与归还!

6 归还图书先提供学号,然后程序会输出该学号借阅的所有图书,然后再通过编号归还!

7 借阅查询可查询某个学生已借但未归还的图书!

项目源码

结构体

先建立结构体,定义结构体成员


typedef struct book
{
char num[10];  
char name[10];  
char auth[10]; 
int count;
int sum;
}Book;
typedef struct borrow
{
char id[20];
char user[20];
char book[20];
char bookid[20];
struct borrow *next;
}BBnode,*BBlink;
struct user 
{ 
char num[10]; 
char pass[15];
char name[15]; 
char sex[10]; 
 
}; 
 
typedef struct unode 
{ 
struct user data; 
struct unode *next; 
}Unode,*Ulink; 
Unode *os;

登录界面函数


int login(Ulink l)
{
 
 

while(!flag)
{
char User_id[10],passWord[10],tmp;
int i=0;
User_id[0]='\0';
password[0]='\0';
textbackground(179);
clrscr();
Gotoxy(33,23);
textcolor(YELLOW);
cputs("ESC = EXIT");
textcolor(WHITE);
textbackground(179);
box(1,1,80,24);
h_line(2,3,78);
gotoxy(15,2);
cputs("Login now please input the User__ID  and Password");
bar_(30,10,23,5,5);

while(User_id[0]=='\0')
{
gotoxy(31,11);
textcolor(YELLOW);
textbackground(5);
cputs("User__ID:");
gotoxy(31,13);
cputs("Password:");
textbackground(179);
textcolor(WHITE);
gotoxy(28,7);
cputs("please input the User__ID!");
textbackground(179);
textcolor(YELLOW);
gotoxy(27,11);
putch(272);
gotoxy(27,13);
putch(' ');
gotoxy(40,11);
tmp=getch();
if(tmp==27)
{
flg=27;
return 0;
}
while(tmp!='\r'&&i<=9&&(tmp>=64&&tmp<=90)||(tmp>=97&&tmp<=122||(tmp>=48&&tmp<=57)))
{
textcolor(YELLOW);
textbackground(5);
	putch(tmp);
	User_id[i]=tmp;
	i++;
	tmp=getch();
	if(tmp==27)
	{
flg=27;
return 0;
}
}
User_id[i]='\0';
}

while(password[0]=='\0')
{
gotoxy(28,7);
textbackground(179);
textcolor(WHITE);
cputs("  input the password now  ");
textbackground(179);
textcolor(YELLOW);
gotoxy(27,13);
putch(272);
gotoxy(27,11);
putch(' ');
gotoxy(40,13);
i=0;
tmp=getch();
if(tmp==27)
{
flg=27;
return 0;
}
while(tmp!='\r'&&i<=10&&(tmp>=64&&tmp<=90)||(tmp>=97&&tmp<=122||(tmp>=48&&tmp<=57)))
{
	textbackground(5);
	putch('*');
 
	password[i]=tmp;
	i++;
	tmp=getch();
	if(tmp==27)
	{
flg=27;
return 0;
}
}
password[i]='\0';
}

if(!strcmp(User_id,"admin")&&!strcmp(password,"admin"))
	{
		return 2;
	}
if(cmps(l,User_id,password))
{	 
	return 1;
}
}
}

选择界面函数


void choose()
{
while(1)
{
 
textbackground(179);
clrscr();
gotoxy(33,2);
textcolor(WHITE);
cputs("Administrastor");
textcolor(YELLOW);
box(1,1,80,24);
h_line(2,3,78);
gotoxy(3,6);
cputs(">>>-------------------------1.User Management----------------------------<<<");
gotoxy(3,10);
cputs(">>>-------------------------2.Book Management----------------------------<<<");
	gotoxy(3,14);
cputs(">>>-------------------------3.Borrow Books-------------------------------<<<");
gotoxy(30,22);
textcolor(RED);
cputs("Please Select!!!");
flg=getch();
if(flg=='2')		
	bookss();									
if(flg=='1')
	users();
if(flg=='3')
	borrow();
if(flg==27)
{
	flg=-1;
	return;
}	
}		
}
void admin()
{
while(1)
{
choose();	
if(flg=='1')	
bookss();
if(flg=='2')
users();
if(flg=='3')
borrow();
if(flg==27)
{
return;
}
}
}

操作界面函数


void user(Ulink h)
{
int flag;
BBlink l,p,r; 
FILE *fp;  
int count=0; 
l=(BBnode*)malloc(sizeof(BBnode)); 
l->next=NULL; 
r=l; 
fp=fopen(bfile,"rb"); 
if(fp==NULL) 
{ 
	fp=fopen(bfile,"wb"); 
} 
while(!feof(fp)) 
{
	p=(BBnode*)malloc(sizeof(BBnode)); 
	if(fread(p,sizeof(BBnode),1,fp))  
	{ 
		p->next=NULL; 
        r->next=p; 
        r=p;  
        count++; 
    } 
} 
	while(1) 
{	
	textbackground(179);
	clrscr();
	textcolor(YELLOW);
	box(1,1,80,24);
	h_line(2,3,78);
	gotoxy(3,2);
	textcolor(RED);
	cputs("A.");
	textcolor(BLUE);
	cputs("my message  ");
	textcolor(RED);
	cputs("B.");
	textcolor(BLUE);
	cputs("modyfy my message  ");
	textcolor(RED);
	cputs("C.");
	textcolor(BLUE);
	cputs("my borrow  ");
	textcolor(RED);
	cputs("D.");
	textcolor(BLUE);
	cputs("search book");
	textcolor(YELLOW);
	gotoxy(50,50);
	flag=getch(); 
    switch(flag)		
	{ 		
	case 'a':
		show(os);
		
		break; 
	case 'b':
		Modify_user(h);
		Save(h);
		
		break;
	case 'c':
		Myborrow();
		break;
	case 'd':
		usersearch();
 
		
		break;
	case 27:
		return;
		
	} 
 
} 
 
}

添加函数

图书的添加,包括用户添加以及管理员添加


void add(blink l)
{ 
Bnode *p,*r,*s; 
char num[10]; 
r=l; 
s=l->next; 
while(r->next!=NULL) 
	r=r->next; 
textcolor(RED);
gotoxy(25,4);
cputs("INPUT THE MESSAGE ABOUT BOOK");
gotoxy(31,10);
textcolor(YELLOW);
cputs("Book ID:");
scanf("%s",num); 
p=(Bnode *)malloc(sizeof(Bnode));  
while(s) 
{ 
	if(strcmp(s->data.num,num)==0) 
	{ 
		textcolor(WHITE);
		gotoxy(25,15);
		cputs("This ID:");
		printf("'%s'",num); 
		cputs("is exist!");    
		gotoxy(25,22);
		cputs("please Press any key to continue...");  
		gotoxy(255,252);
		getch();                    
		return; 
	} 
	s=s->next; 
} 
strcpy(p->data.num,num); 
gotoxy(31,12);
textcolor(YELLOW);
cputs("Input Book name:"); 
scanf("%s",p->data.name); 
gotoxy(31,14);
cputs("input your Book auth:"); 
scanf("%s",p->data.auth); 
gotoxy(31,16);
cputs("input your Book count:"); 
scanf("%d",&p->data.count); 
bookcount=p->data.count+bookcount;
p->data.sum=0;
p->next=NULL; 
r->next=p; 
r=p; 
gotoxy(30,22);
textcolor(RED);
cputs("Add Book Success !!!");
getch();
textcolor(YELLOW);
} 
 
 
void Add(Ulink l)
{ 
Unode *p,*r,*s; 
char num[10]; 
r=l; 
s=l->next; 
while(r->next!=NULL) 
	r=r->next; 
textcolor(RED);
gotoxy(25,4);
cputs("INPUT THE MESSAGE ABOUT BOOK");
gotoxy(31,10);
textcolor(YELLOW);
cputs("User ID:");
scanf("%s",num); 
p=(Unode *)malloc(sizeof(Unode));  
while(s) 
{ 
	if(strcmp(s->data.num,num)==0) 
	{ 
		gotoxy(25,15);
		cputs("This ID:");
		printf("'%s'",num); 
		cputs("is exist!");    
		gotoxy(25,22);
		textcolor(RED);
		cputs("please Press any key to continue...");  
		gotoxy(255,252);
		getch();                    
		return; 
	} 
	s=s->next; 
} 
strcpy(p->data.num,num); 
gotoxy(31,12);
textcolor(YELLOW);
cputs("Input Password:"); 
scanf("%s",p->data.pass); 
gotoxy(31,14);
cputs("input your name:"); 
scanf("%s",p->data.name); 
gotoxy(31,16);
cputs("input the sex:"); 
scanf("%s",p->data.sex); 
p->next=NULL; 
r->next=p; 
r=p; 
gotoxy(30,22);
cputs("Add User Success !!!");
usercount++;
getch();
textcolor(YELLOW);
} 

查找函数

用户查找以及管理员查找



void qur(blink l)
{ 
int sel; 
char findmess[20]; 
Bnode *p; 
 
if(!l->next) 
{ 
gotoxy(30,4);
textcolor(WHITE);
     cputs("Not Find Bookdata!!!"); 
	 getch();
    return; 
} 
textcolor(RED);
gotoxy(25,4);
cputs("Please Select Search  Type !");
gotoxy(10,8);
textcolor(WHITE);
cputs("1.Search by ID");
gotoxy(10,10);
cputs("2.Search by Name");
gotoxy(10,12);
cputs("Please Select 1 or 2:");
scanf("%d",&sel); 
if(sel==1) 
{
	gotoxy(36,8);
	textcolor(YELLOW);
	cputs("Input the search ID:"); 
	scanf("%s",findmess); 
	p=locate(l,findmess,"num"); 
	if(p) 
	{ 
		gotoxy(36,12);
		textcolor(WHITE);
		cputs("Book ID:");
		printf("%s",p->data.num);
		gotoxy(36,14);
		textcolor(WHITE);
		cputs("Book Name:");
		printf("%s",p->data.name);
		gotoxy(36,16);
		textcolor(WHITE);
		cputs("Book author:");
		printf("%s",p->data.auth);
		gotoxy(36,18);
		textcolor(WHITE);
		cputs("Book count:");
		printf("%d",p->data.count);
		getch();
		textcolor(YELLOW);
		gotoxy(30,21);
		cputs("Search Success !!");
	}
	else 
	{
		gotoxy(30,22);
		textcolor(RED);
		cputs("Not finde !!!"); 
		getch();
	}
}	
else if(sel==2) 
{ 
	gotoxy(36,8);
	textcolor(YELLOW);
	cputs("Input the search name:");
	scanf("%s",findmess); 
	p=locate(l,findmess,"name"); 		
	if(p) 
	{ 
		gotoxy(36,12);
		textcolor(WHITE);
		cputs("Book ID:");
		printf("%s",p->data.num);
		gotoxy(36,14);
		textcolor(WHITE);
		cputs("Book Name:");
		printf("%s",p->data.name);
		gotoxy(36,16);
		textcolor(WHITE);
		cputs("Book author:");
		printf("%s",p->data.auth);
		gotoxy(36,18);
		textcolor(WHITE);
		cputs("Book count:");
		printf("%d",p->data.count);
		getch();
		textcolor(YELLOW);
	} 
	else 
	{
		textcolor(RED);
		gotoxy(30,22);
		cputs("Not finde !!!"); 
	}
} 
else 
{
	textcolor(RED);
	gotoxy(30,22); 
	cputs("Error !!"); 
	getch();
}
} 
 

void usersearch()
{ 
int sel; 
char findmess[20]; 
Bnode *p; 
blink l; 
FILE *fp;  
int count=0; 
Bnode *P,*r;
l=(Bnode*)malloc(sizeof(Bnode)); 
l->next=NULL; 
r=l; 
fp=fopen(file,"rb"); 
if(fp==NULL) 
{ 
	fp=fopen(file,"wb"); 
 } 
while(!feof(fp)) 
{ 
    P=(Bnode*)malloc(sizeof(Bnode)); 
    if(fread(P,sizeof(Bnode),1,fp))  
    { 
        P->next=NULL; 
		bookcount=bookcount+P->data.count;
		booksum=booksum+P->data.sum;
        r->next=P; 
        r=P;  
        count++; 
    }
} 
fclose(fp);  
 
 
if(!l->next) 
{ 
gotoxy(30,4);
textcolor(WHITE);
     cputs("Not Find Bookdata!!!");
	 getch();
    return; 
} 
textcolor(RED);
gotoxy(25,4);
cputs("Please Select Delete  Type !");
gotoxy(10,8);
textcolor(WHITE);
cputs("1.Search by ID");
gotoxy(10,10);
cputs("2.Search by Name");
gotoxy(10,12);
cputs("Please Select 1 or 2:");
scanf("%d",&sel); 
if(sel==1) 
{
	gotoxy(36,8);
	textcolor(YELLOW);
	cputs("Input the search ID:"); 
	scanf("%s",findmess); 
	p=locate(l,findmess,"num"); 
	if(p) 
	{ 
		gotoxy(36,12);
		textcolor(WHITE);
		cputs("Book ID:");
		printf("%s",p->data.num);
		gotoxy(36,14);
		textcolor(WHITE);
		cputs("Book Name:");
		printf("%s",p->data.name);
		gotoxy(36,16);
		textcolor(WHITE);
		cputs("Book author:");
		printf("%s",p->data.auth);
		gotoxy(36,18);
		textcolor(WHITE);
		cputs("Book count:");
		printf("%d",p->data.count-p->data.sum);
		getch();
		textcolor(YELLOW);
	}
	else 
	{
		gotoxy(30,22);
		textcolor(RED);
		cputs("Not finde !!!"); 
		getch();
	}
}	
else if(sel==2)
{ 
	gotoxy(36,8);
	textcolor(YELLOW);
	cputs("Input the search name:");
	scanf("%s",findmess); 
	p=locate(l,findmess,"name"); 		
	if(p) 
	{ 
		gotoxy(36,12);
		textcolor(WHITE);
		cputs("Book ID:");
		printf("%s",p->data.num);
		gotoxy(36,14);
		textcolor(WHITE);
		cputs("Book Name:");
		printf("%s",p->data.name);
		gotoxy(36,16);
		textcolor(WHITE);
		cputs("Book author:");
		printf("%s",p->data.auth);
		gotoxy(36,18);
		textcolor(WHITE);
		cputs("Book count:");
		printf("%d",(p->data.count-p->data.sum));
		getch();
		textcolor(YELLOW);
	} 
	else 
	{
		textcolor(RED);
		gotoxy(30,22);
		cputs("Not finde !!!"); 
	}
} 
else 
{
	textcolor(RED);
	gotoxy(30,22); 
	cputs("Error !!"); 
	getch();
}
} 
 

int cmpbook(blink l,char id[],char na[])
{ 
char findm[20];
Bnode *p; 
if(!l->next) 
{ 
	gotoxy(25,4);
	textcolor(RED);
     cputs("Not Find Book!!!"); 
	 getch();
    return 0; 
} 
strcpy(findm,id);
	p=locate(l,findm,"num"); 
	if(p) 
	{ 
		strcpy(findm,na);
		p=locate(l,findm,"name"); 		
		if(p) 
		{ 
			return 1;	
		} 
		else 
		{
			textcolor(RED);
			gotoxy(30,22);
			cputs("Book name is NULL !!!"); 
			getch();
			return 0;
		}
	}
	else 
	{
		gotoxy(30,22);
		textcolor(RED);
		cputs("Book id is NULL !!!"); 
		getch();
		return 0;
	}
	
 
 
	
	
 
} 

删除函数

图书的删除


void del(blink l) 
{ 
	int sel; 
	Bnode *p,*r; 
	char findmess[20]; 
	if(!l->next) 
	{ 
		gotoxy(25,4);
		textcolor(RED);
		cputs("=====>not thing could delete!\n"); 
		getch();
		return; 
	} 
	textcolor(RED);
	gotoxy(25,4);
	puts("Please Select Delete  Type !");
	gotoxy(10,8);
	
	textcolor(WHITE);
	cputs("1.Delete by Book ID");
	gotoxy(10,10);
	cputs("2.Delete by Book Name");
	gotoxy(10,12);
	cputs("Please Select 1 or 2:");
	scanf("%d",&sel); 
	if(sel==1)     
	{ 
		gotoxy(36,8);
		textcolor(YELLOW);
		cputs("Input the delete ID:"); 
		scanf("%s",findmess); 
		p=locate(l,findmess,"num"); 
		if(p) 
		{ 
			bookcount=bookcount-p->data.count;
			r=l; 
			while(r->next!=p) 
				r=r->next; 
			r->next=p->next; 
			free(p); 
			gotoxy(30,22);
			textcolor(RED);
			cputs("Delete success!\n");     
			textcolor(YELLOW);  
		} 
		else 
		{
	textcolor(RED);
	gotoxy(30,22); 
	cputs("Error !!"); 
		}
	} 
	else if(sel==2) 
	{ 
		gotoxy(36,8);
		textcolor(YELLOW);
		cputs("Input the delete name:"); 
		scanf("%s",findmess); 
		p=locate(l,findmess,"name"); 
		if(p) 
		{ 
			r=l; 
			while(r->next!=p) 
				r=r->next; 
			r->next=p->next; 
			free(p); 
			gotoxy(30,22);
			textcolor(RED);
			cputs("Delete success!\n"); 
			bookcount--;
			textcolor(YELLOW);  
		} 
		else
		{
			gotoxy(25,18);
			cputs("Not find!!"); 
		}
	} 
	else
	{
	textcolor(RED);
	gotoxy(30,22); 
	cputs("Error !!");  
	}
	getch();
	textcolor(YELLOW);
} 

借书管理函数


void borrow()
{
while(1)
{
int flag;
BBlink l,p,r; 
FILE *fp;  
int count=0; 
l=(BBnode*)malloc(sizeof(BBnode)); 
l->next=NULL; 
r=l; 
fp=fopen(bfile,"rb"); 
if(fp==NULL) 
{ 
	fp=fopen(bfile,"wb"); 
} 
while(!feof(fp)) 
{
	p=(BBnode*)malloc(sizeof(BBnode)); 
	if(fread(p,sizeof(BBnode),1,fp))  
	{ 
		p->next=NULL; 
        r->next=p; 
        r=p;  
        count++; 
    } 
	borrowcount=count;
} 
while(1) 
{	
	textbackground(179);
	clrscr();
	textcolor(YELLOW);
	box(1,1,80,24);
	h_line(2,3,78);
	gotoxy(3,2);
	textcolor(RED);
	cputs("B");
	textcolor(BLUE);
	cputs("orrow book  ");
	textcolor(RED);
	cputs("R");
	textcolor(BLUE);
	cputs("eturn book  ");
	textcolor(RED);
	cputs("S");
	textcolor(BLUE);
	cputs("earch borrow  ");
	textcolor(YELLOW);
	printf("count: (borrow=%d)",borrowcount);
	textcolor(RED);
	gotoxy(50,50);
	flag=getch(); 
    switch(flag)		
	{ 		
	case 'b':
		Add_borrow(l);
		
		break; 
	case 'r':
		Del_borrow(l);
		Save_borrow(l);
		break;
	case 's':
		Qur_borrow(l);
		break;
	case 27:
		return;
		
	} 
     } 	 
  }
}
 

信息储存函数

图书信息的储存


*******借书信息保存*******/
void Save_borrow(BBlink l) 
{ 
 FILE* fp; 
 BBnode *p; 
 int flag=1,count=0; 
 fp=fopen(bfile,"wb"); 
 if(fp==NULL) 
 { 
gotoxy(35,12);
	textcolor(RED);
      cputs("open error!"); 
      exit(1); 
 } 
 p=l->next; 
 while(p) 
 { 
      if(fwrite(p,sizeof(BBnode),1,fp)==1) 
      { 
          p=p->next; 
          count++; 
      } 
      else 
      { 
          flag=0; 
          break; 
      } 
} 
if(flag) 
{ 
textcolor(RED);
gotoxy(30,24);
 
}
fclose(fp); 
} 

还书函数


 
void Del_borrow(BBlink l) 
{ 
		int sel; 
	BBnode *p,*r; 
	Bnode *L;
	char findmess[20];
	FILE *fp; 
Bnode *P,*R,*Q;
L=(Bnode*)malloc(sizeof(Bnode)); 
L->next=NULL; 
R=L; 
fp=fopen(file,"rb"); 
if(fp==NULL) 
{ 
	fp=fopen(file,"wb");
 }
while(!feof(fp))
{
    P=(Bnode*)malloc(sizeof(Bnode));
    if(fread(P,sizeof(Bnode),1,fp)) 
    {
        P->next=NULL;
        R->next=P;
        R=P; 
    }
}
fclose(fp); 
 
	if(!l->next)
	{
		gotoxy(30,4);
		textcolor(RED);
		cputs("not Book could Return!\n");
		getch();
		return;
	}
	textcolor(RED);
	gotoxy(25,4);
	puts("Please Select Return  Type !");
	gotoxy(10,8);
 
	textcolor(WHITE);
	cputs("1.Return by Borrow ID");
	gotoxy(10,10);
	cputs("2.Return by book name");
	gotoxy(10,12);
	cputs("Please Select 1 or 2:");
	scanf("%d",&sel);
	if(sel==1)
	{
		gotoxy(36,8);
		textcolor(YELLOW);
		cputs("Input the Borrow ID:");
		scanf("%s",findmess);
		p=Locate_borrow(l,findmess,"num");
		if(p)
		{
 
				Q=locate(L,findmess,"num");
				if(Q) 
				{ 
					Q->data.sum=Q->data.sum-1;
						save(L);
				} 
			r=l; 
			while(r->next!=p) 
				r=r->next; 
			r->next=p->next; 
			free(p); 
			gotoxy(30,22);
			textcolor(RED);
			cputs("Return success!\n"); 
			borrowcount--;
			getch();
			textcolor(YELLOW);  
		} 
		else 
		{
			gotoxy(30,22);
			textcolor(RED);
			cputs("Note find !!"); 
			getch();
			
		}
	} 
	else if(sel==2) 
	{ 
		gotoxy(36,8);
		textcolor(YELLOW);
		cputs("Input the Book name:"); 
		scanf("%s",findmess); 
		p=Locate_borrow(l,findmess,"book");
		if(p) 
		{ 
			
				Q=locate(L,findmess,"name"); 
				if(Q) 
				{ 
					Q->data.sum=Q->data.sum-1;
						save(L);
				} 
			
			r=l; 
			while(r->next!=p) 
				r=r->next; 
			r->next=p->next; 
			free(p); 
			gotoxy(30,22);
			textcolor(RED);
			cputs("Borrow success!\n"); 
			borrowcount--;
			getch();
			textcolor(YELLOW);  
		} 
		else
		{
			gotoxy(30,18);
			textcolor(RED);
			cputs("Not find!!"); 
			getch();
		}
	} 
		
	else
	{
		gotoxy(30,22);
		textcolor(RED);
		cputs("Not finde !!"); 
		getch();
	}
	textcolor(YELLOW);
} 

修改函数

也分为用户和管理员两种情况 



void Modify(Ulink l) 
{ 
	Unode *p; 
	char findmess[20]; 
	if(!l->next) 
	{
		gotoxy(30,4);
		textcolor(RED);
		cputs("not thing could modify!"); 
		getch();
		return; 
	} 
	gotoxy(30,4);
	textcolor(RED);
	cputs("Modify User Message");
	gotoxy(25,8);
	textcolor(YELLOW);
	cputs("input the User Id:");
	scanf("%s",findmess); 
	p=Locate(l,findmess,"num"); 
	if(p) 
	{ 
		textcolor(YELLOW);
		gotoxy(25,10);
		printf("Inpute The New ID(old:%s):",p->data.num); 
		scanf("%s",p->data.num); 
		gotoxy(25,12);
		printf("Input The New Password(old:%s):",p->data.pass); 
		scanf("%s",p->data.pass); 
		gotoxy(25,14);
		printf("Input The New Name(old:%s):",p->data.name); 
		scanf("%s",p->data.name); 
		gotoxy(25,16);
		printf("Input The New Sex(old:%s):",p->data.sex); 
		scanf("%s",p->data.sex); 
		gotoxy(30,20);
		textcolor(RED);
		cputs("Modify Success !!!"); 
		getch();
		textcolor(YELLOW);
	} 
	else 
	{	
		gotoxy(30,16);
		textcolor(RED);
		cputs("Not Finde !!!"); 
		getch();
	}
} 
 
 
 
void Modify_user(Ulink l)
{ 
	Unode *p; 
	char findmess[20]; 
	if(!l->next) 
	{
		gotoxy(30,4);
		textcolor(RED);
		cputs("not thing could modify!"); 
		getch();
		return; 
	} 
	gotoxy(30,4);
	textcolor(RED);
	cputs("Modify User Message");
	gotoxy(33,8);
	textcolor(YELLOW);
	strcpy(findmess,os->data.num);
	printf("your id:%s",findmess);
	p=Locate(l,findmess,"num"); 
	if(p) 
	{ 
		textcolor(YELLOW);
		gotoxy(24,10);
		printf("Input The New Password(old:%s):",p->data.pass); 
		scanf("%s",p->data.pass); 
		gotoxy(24,12);
		printf("Input The New Name(old:%s):",p->data.name); 
		scanf("%s",p->data.name); 
		gotoxy(24,14);
		printf("Input The New Sex(old:%s):",p->data.sex); 
		scanf("%s",p->data.sex); 
		gotoxy(31,18);
		textcolor(RED);
		cputs("Modify Success !!!"); 
		getch();
		textcolor(YELLOW);
	} 
	else 
	{	
		gotoxy(30,16);
		textcolor(RED);
		cputs("Not Finde !!!"); 
		getch();
	}
} 

添加借书函数



void Add_borrow(BBlink l) 
{ 
Ulink H; 
FILE *Fp;  
Unode *Q,*T;
blink L; 
FILE *FP;  
int ttl;
 
Bnode *P,*R;
char bookid[20];
char bookname[20];
char userid[20];
BBnode *p,*r,*s; 
char num[10]; 
r=l; 
s=l->next; 
while(r->next!=NULL) 
	r=r->next; 
L=(Bnode*)malloc(sizeof(Bnode)); 
L->next=NULL; 
R=L; 
FP=fopen(file,"rb"); 
if(FP==NULL) 
{ 
	FP=fopen(file,"wb"); 
 } 
while(!feof(FP)) 
{ 
    P=(Bnode*)malloc(sizeof(Bnode)); 
    if(fread(P,sizeof(Bnode),1,FP))  
    { 
        P->next=NULL; 
		bookcount=bookcount+P->data.count;
        R->next=P; 
        R=P;  
 
    } 
} 
fclose(FP);  
 
 
H=(Unode*)malloc(sizeof(Unode)); 
H->next=NULL; 
T=H;
Fp=fopen(ufile,"rb"); 
if(Fp==NULL) 
{ 
	Fp=fopen(ufile,"wb"); 
 } 
while(!feof(Fp)) 
{ 
    Q=(Unode*)malloc(sizeof(Unode));
    if(fread(Q,sizeof(Unode),1,Fp))  
    { 
        Q->next=NULL; 
        T->next=Q; 
        T=Q;  
    } 
} 
fclose(Fp); 
textcolor(RED);
gotoxy(25,4);
cputs("Please input thease message");
gotoxy(30,10);
textcolor(YELLOW);
cputs("Input Borrow ID:");
scanf("%d",&ttl);
itoa(ttl,num,10) ;
p=(BBnode *)malloc(sizeof(BBnode));
while(s) 
{ 
	if(strcmp(s->id,num)==0) 
	{ 
		gotoxy(30,15);
		cputs("Borrow ID:");
		printf("'%s'",num); 
		cputs("is exist!");    
		gotoxy(26,22);
		textcolor(RED);
		cputs("please Press any key to continue...");  
		gotoxy(255,252);
		getch();                    
		return; 
	} 
	s=s->next; 
} 
strcpy(p->id,num);
gotoxy(31,12);
textcolor(YELLOW);
cputs("Input book id:"); 
scanf("%s",bookid);
gotoxy(31,14);
textcolor(YELLOW);
cputs("Input book name:"); 
scanf("%s",bookname); 
if(cmpbook(L,bookid,bookname))
{
	strcpy(p->bookid,bookid);
	strcpy(p->book,bookname);
	gotoxy(31,16);
cputs("input your ID:"); 
scanf("%s",userid); 
if(cmpuser(H,userid))
{
	strcpy(p->user,userid);
	p->next=NULL; 
r->next=p; 
r=p; 
if(changeb(L,bookid))
{
gotoxy(30,22);
cputs("Borrow Success !!!");
Save_borrow(l);
borrowcount++;
 
getch();
}
}
 
}
 
textcolor(YELLOW);
} 

查找借书函数

查找自己借了哪些书


void Myborrow()
{
int i;
 
BBlink l,p,r; 
FILE *fp;  
int count=0; 
l=(BBnode*)malloc(sizeof(BBnode)); 
l->next=NULL; 
r=l; 
fp=fopen(bfile,"rb"); 
if(fp==NULL) 
{ 
	fp=fopen(bfile,"wb"); 
} 
i=6;
while(!feof(fp)) 
{
 
 
	
	p=(BBnode*)malloc(sizeof(BBnode)); 
	if(fread(p,sizeof(BBnode),1,fp))  
	{ 
		textcolor(WHITE);
		gotoxy(30,4);
		cputs("Your borrow book");
		
		if(strcmp(p->user,os->data.num)==0)
		{
			textcolor(YELLOW);
 
			gotoxy(20,i);
			printf("Borrow ID:%s\tBook id:%s\tBook name:%s",p->id,p->bookid,p->book);
			i++;
 
			p->next=NULL; 
			r->next=p; 
			r=p;  
			count++; 
		}
    } 
	myborrow=count;
	if(myborrow==0)
	{
		textcolor(YELLOW);
		gotoxy(30,13);
		cputs("You  no borrow !!");
 
 
	}
 
 
 
}
fclose(fp);
textcolor(YELLOW);
	gotoxy(65,2);
	printf("(borrow=%d)",myborrow);
		
	getch();
 
}

借书管理函数


void borrow()
{
while(1)
{
int flag;
BBlink l,p,r; 
FILE *fp;  
int count=0; 
l=(BBnode*)malloc(sizeof(BBnode)); 
l->next=NULL; 
r=l; 
fp=fopen(bfile,"rb"); 
if(fp==NULL) 
{ 
	fp=fopen(bfile,"wb"); 
} 
while(!feof(fp)) 
{
	p=(BBnode*)malloc(sizeof(BBnode)); 
	if(fread(p,sizeof(BBnode),1,fp))  
	{ 
		p->next=NULL; 
        r->next=p; 
        r=p;  
        count++; 
    } 
	borrowcount=count;
} 
while(1) 
{	
	textbackground(179);
	clrscr();
	textcolor(YELLOW);
	box(1,1,80,24);
	h_line(2,3,78);
	gotoxy(3,2);
	textcolor(RED);
	cputs("B");
	textcolor(BLUE);
	cputs("orrow book  ");
	textcolor(RED);
	cputs("R");
	textcolor(BLUE);
	cputs("eturn book  ");
	textcolor(RED);
	cputs("S");
	textcolor(BLUE);
	cputs("earch borrow  ");
	textcolor(YELLOW);
	printf("count: (borrow=%d)",borrowcount);
	textcolor(RED);
	gotoxy(50,50);
	flag=getch(); 
    switch(flag)		
	{ 		
	case 'b':
		Add_borrow(l);
		
		break; 
	case 'r':
		Del_borrow(l);
		Save_borrow(l);
		break;
	case 's':
		Qur_borrow(l);
		break;
	case 27:
		return;
		
	} 
 
} 	
 
}
 
 
}

主函数


main()
{
 
Ulink h,os; 
FILE *fp;  
Unode *p,*r;
h=(Unode*)malloc(sizeof(Unode)); 
h->next=NULL; 
r=h; 
fp=fopen(ufile,"rb"); 
if(fp==NULL) 
{ 
	fp=fopen(ufile,"wb"); 
 } 
while(!feof(fp)) 
{ 
    p=(Unode*)malloc(sizeof(Unode)); 
    if(fread(p,sizeof(Unode),1,fp)) 
    {
        p->next=NULL;
        r->next=p;
        r=p; 
 
    }
}
fclose(fp);
system("wellcome");
	if(flg==27)
	{
		flg=-1;
		return;
	}
		while(1)
		{
			flag=login(h);
			if(flg==27)
				{
					flg=-1;
					break;
				}
 
				if(flag==2)
				{
					choose();
					flag=0;
				}
				if(flag==1)
				{
					user(h);
					flag=0;
				}
 
		}
 
}

总结

     今天的代码量有点小多,难度也不小,用了大量的链表来储存数据,还有一些功能因为篇幅的问题没有放上来,总的来说,这个图书管理系统的功能是很全面的,无论从哪个角度来看。当然啦。有兴趣的同学可以进群领取完整的源码看看,绝对是一个不错的机会,可以说,你要是学会了这个系统,你的C语言在我看来就完全没有问题了,而且在数据结构一块,你也算是小成了,所以希望大家可以认真学习,争取早日掌握。

     这也是2022年的第一篇文章了,希望2022继续加油,向大家分享更多有趣的、有用的知识,十分感谢大家的一路支持,后续我还会发布更多的项目源或者学习资料,希望大家可以持续关注。

念七可爱卡通情侣头像 可做表情包的卡通情侣头像

到此这篇关于C语言大作业之图书管理系统的实现详程的文章就介绍到这了,更多相关C语言 图书管理系统内容请搜索编程网以前的文章或继续浏览下面的相关文章希望大家以后多多支持编程网!

--结束END--

本文标题: C语言大作业之图书管理系统的实现详程

本文链接: https://www.lsjlt.com/news/163484.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • C语言大作业之图书管理系统的实现详程
    目录主要内容概要设计项目源码结构体登录界面函数选择界面函数操作界面函数添加函数查找函数删除函数借书管理函数信息储存函数还书函数修改函数添加借书函数查找借书函数借书管理函数主函数总结序...
    99+
    2022-11-13
  • JAVA大作业之图书管理系统实现全解
    目录一、简介二、系统的设计1、Book包:1.1、book类:1.2、bookList类:2、Operation包:2.1、增加书籍:2.2、删除书籍:2.3、借阅书籍2.4、归还书...
    99+
    2022-11-13
  • C语言实现图书馆管理系统
    本文实例为大家分享了C语言实现图书馆管理系统的具体代码,供大家参考,具体内容如下 全部代码如下: #include <stdio.h> #include<str...
    99+
    2022-11-12
  • C语言图书管理系统实验
    本文实验为大家分享了C语言图书管理系统的具体代码,供大家参考,具体内容如下 实验要求: 1、图书信息:包括ISBN、书名、主编、出版社、定价 2、功能: (1)插入:若表中不存在新...
    99+
    2022-11-13
  • C语言实现图书管理系统开发
    本文实例为大家分享了C语言实现图书管理系统的具体代码,供大家参考,具体内容如下 程序介绍 图书管理系统主要有以下功能: 1、录入图书信息。2、实现删除功能,即输入图书号删除相应的记录...
    99+
    2022-11-13
    C语言图书管理系统 C语言图书系统 C语言图书管理
  • C语言如何实现图书管理系统
    这篇文章将为大家详细讲解有关C语言如何实现图书管理系统,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。主要内容        开发一个图书信息管理系统,图书信息包括:...
    99+
    2023-06-28
  • C语言怎么实现图书管理系统
    要实现一个图书管理系统,可以按照以下步骤进行:1. 定义图书结构体:首先要定义一个图书的结构体,包括图书的编号、名称、作者等信息。`...
    99+
    2023-08-09
    C语言
  • C语言实现图书管理系统课程设计
    目录设计要求实现代码运行结果本文实例为大家分享了C语言实现图书管理系统的具体代码,供大家参考,具体内容如下 设计要求 设计图书管理系统 要求如下: 1.对书名,作者,编号,出版单位,...
    99+
    2022-11-13
  • C语言单链表实现图书管理系统
    本文实例为大家分享了C语言单链表实现图书管理系统的具体代码,供大家参考,具体内容如下 单链表实现的图书管理系统相比于结构体实现的管理系统,可以随时开辟新的空间,可以增加书的信息 单链...
    99+
    2022-11-13
  • C语言如何实现图书馆管理系统
    这篇文章主要介绍了C语言如何实现图书馆管理系统,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。全部代码如下:#include <stdio.h>#incl...
    99+
    2023-06-20
  • C语言链表实现简单图书管理系统
    本文实例为大家分享了C语言链表实现图书管理系统的具体代码,供大家参考,具体内容如下 实现功能: 用C语言制作图书管理系统,实现图书进行登记书籍,浏览书籍,借阅书籍,归还书籍,书籍排序...
    99+
    2022-11-13
  • C语言实现图书管理系统的示例分析
    这篇文章将为大家详细讲解有关C语言实现图书管理系统的示例分析,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。具体内容如下实验要求:图书信息:包括ISBN、书名、主编、出版社、定价2、功能:(1)插入:若表中...
    99+
    2023-06-29
  • C语言实现图书管理系统(文件数据库)
    本文实例为大家分享了C语言实现图书管理系统的具体代码,供大家参考,具体内容如下 简介 c语言的一个大作业,发上来纪念下嘿嘿。写的不是很好,很多东西都揉在一起来,不过注释写的也挺多,希...
    99+
    2022-11-13
  • C语言中单链表如何实现图书管理系统
    小编给大家分享一下C语言中单链表如何实现图书管理系统,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!具体内容如下单链表实现的图书管理系统相比于结构体实现的管理系统,...
    99+
    2023-06-29
  • C语言如何实现图书管理系统的文件数据库
    本文小编为大家详细介绍“C语言如何实现图书管理系统的文件数据库”,内容详细,步骤清晰,细节处理妥当,希望这篇“C语言如何实现图书管理系统的文件数据库”文章能帮助大家解决疑惑,下面跟着小编的思路慢慢深入,一起来学习新知识吧。题目要求简单文件数...
    99+
    2023-06-29
  • C++实现图书管理系统课程设计
    本文实例为大家分享了C++实现图书管理系统的具体代码,供大家参考,具体内容如下 大一 C++课设,没有用分文件的形式,只是把菜单页面单独分开了。用的是链表,都是一些基础的东西。另外采...
    99+
    2022-11-13
  • Java实战之图书管理系统的实现
    目录一、项目运行二、效果图三、核心代码登录控制层图书管理控制层读者管理控制层一、项目运行 环境配置: Jdk1.8 + Tomcat8.5 + mysql + Eclispe(Int...
    99+
    2022-11-13
  • c语言实现学生管理系统详解
    目录infor.htest.cinfor.c总结 该学生管理系统的实现是通过分文件的方式来写的,infor.h 文件为头文件,源文件infor.c实现源文件tes...
    99+
    2022-11-12
  • C++实现图书管理系统(文件操作与类)
    本文实例为大家分享了C++实现图书管理系统的具体代码,供大家参考,具体内容如下 (1)定义图书类; (2)图书信息包括:书名name,价格price,库存num; (3)可以查询、增...
    99+
    2022-11-13
  • C语言实现企业员工管理系统开发
    本文实例为大家分享了C语言实现企业员工管理系统的具体代码,供大家参考,具体内容如下 程序介绍 系统介绍 企业员工信息管理系统主要是对企业员工的基本信息进行增、删、改、查的相关操作,以...
    99+
    2022-11-13
    C语言企业员工管理系统 C语言企业员工系统 C语言员工管理系统
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作