Project C - book borrowing system

Posted by outsidaz on Wed, 09 Mar 2022 21:34:06 +0100

Title: book borrowing system
Function: the system requires the following functions:
1. Administrator mode: manage book information and customer information;
2. Customer mode: complete customer borrowing query requirements.
3. Addition, deletion, modification and query function: complete the addition, deletion, modification, query and display of books.
Step by step implementation: 1. Preliminarily complete the overall design, set up the framework, determine the interface of man-machine dialogue and the number of functions. 2. 2. 3. The function of modifying the password can be completed only when the information required by the student is input correctly. Otherwise, the function of modifying the password can be completed.
Requirements: 1. Program design in C language;
2. Using structure array and linked list to realize book information expression and query, and fully reflect the knowledge of data structure;
3. Each functional module of the system is required to be realized in the form of function;
4. Friendly interface (good human-computer interaction), and the program should be annotated.
5. The sorting and searching method used in the program needs to be realized by the method learned in the data structure, which requires the method to be practical and efficient.

1, Overall design

1. Data structure

struct book
{
    long num;
    char name[20];
    char publish[20];/*press*/
    struct time
    {
        int day;
        int month;
        int year;
    }t;
    int jie;/*Borrow*/
}bk[20];

2. Function prototype declaration

void xinxi()
int mymainmenu()
int mimayanzheng()
void xiugaimima()
int adm()
int peo()
void show_all_book()
void showbook_name()
void showbook_num()
void yijieyue()
void weijieyue()
void show()
void jie_name()
void jie_num()
void jieyue()
void xiugai_name()
void xiugai_num()
void dele_all()
void dele_name()
void dele_num()
void dele()
void xiugai()
void main()

2, Source code

/* [Self study] website Collection http://www.zixue7.com */

//#include "stdafx.h"

#include"stdio.h"
#include"conio.h"
#include"string.h"
#include"stdlib.h"
int N;
char mima[20]="mm";
/**********Define book structure type book*******/
struct book
{
    long num;
    char name[20];
    char publish[20];/*press*/
    struct time
    {
        int day;
        int month;
        int year;
    }t;
    int jie;/*Borrow*/
}bk[20];
/********Establish library information database********/
void xinxi()
{
    int i;
    system("CLS");
    printf("\t\t         =====================        \n");
    printf("\t\t               Input book information              \n");
    printf("\t\t         =====================        \n\n");
	printf("\t\t Please enter the quantity you want to enter:");
	scanf("%d",&N);
    for(i=0;i<N;i++)
    {
		printf("\t\t Please enter page%d Number of this book:",i+1);
        scanf("%d",&bk[i].num);
        printf("\t\t Please enter page%d Title of the book:",i+1);
        scanf("%s",bk[i].name);
        printf("\t\t Please enter page%d The publisher of this book:",i+1);
        scanf("%s",bk[i].publish);
        printf("\t\t Please enter page%d Publication date of this book(Separated by commas):",i+1);
        scanf("%d,%d,%d",&bk[i].t.year,&bk[i].t.month,&bk[i].t.day);
        printf("\t\t Has the book been borrowed,Borrowed input'1',Not borrowed input'0':");
        scanf("%d",&bk[i].jie);
		printf("--------------------------------------------------------------------------------\n");
    }
	system("CLS");
    printf("\t\t         =====================        \n");
    printf("\t\t               Information entry completed              \n");
    printf("\t\t         =====================        \n");
    printf("\n\t\t             press any key to continue...\n");
}
/******Main menu******/
int mymainmenu()
{
    int x;
	printf("\n\n\n\n");
    printf("\t\t|-------------------------------------------------------------|\n");
    printf("\t\t|                                         |\n");
    printf("\t\t|        ======================        |\n");
    printf("\t\t|           Welcome to the library management system          |\n");
    printf("\t\t|        ======================        |\n");
    printf("\t\t|                                         |\n");
    printf("\t\t|           1.administrator mode                   |\n");
    printf("\t\t|           2.Customer model                     |\n");
    printf("\t\t|           3.Exit the system                     |\n");
    printf("\t\t|--------------------------------------------------------------|\n");
    printf("\n\t\t Please enter your choice:");
    scanf("%d",&x);
    return x;
}
/**************Administrator password authentication*****************/
int mimayanzheng()
{
	char temp_mima[20];/*Used to store the password entered by the user*/
    printf("\n");
    printf("\t\t         ======================        \n");
    printf("\t\t            Welcome to administrator mode            \n");
    printf("\t\t         ======================        \n");
    printf("\n");
    printf("\t\t          Please input a password:");
    scanf("%s",temp_mima);
	if(strcmp(temp_mima,mima)==0)/*Compare passwords*/
		return 1;
	else
		return 0;
}
/**************Change password***********/
void xiugaimima()
{
	char temp_mima[20],temp1[20],temp2[20];/* temp_mima[20]It is used to store the password entered by the user, temp1[20],temp2[
20]It is used to store the two modified passwords entered by the user*/    
printf("\n");
    printf("\t\t         ======================        \n");
    printf("\t\t                 Change Password                 \n");
    printf("\t\t         ======================        \n");
    printf("\n");
	printf("\t\t           Please enter the original password:");
	scanf("\t\t%s",temp_mima);
    while(1)
    {
	if(strcmp(temp_mima,mima)==0)/*Compare passwords*/
	{
		printf("\t Please enter a new password:");
		scanf("%s",temp1);
		printf("\t Please enter again:");
		scanf("%s",temp2);
		if(strcmp(temp1,temp2)==0)/*If you enter the same new password twice*/
		{
			printf("\t Password modified successfully!!Please remember the password,Any key return...");
			strcpy(mima,temp1);
			getch();break;
		}
		else
		{
			printf("\t The passwords entered twice are different. Modification failed!Any key return...");
			getch();
			break;
		}
	}
	else
	{
		printf("\t Wrong password!You cannot change your password!Any key return...");
		getch();
		break;
	}
}
}	
/**************Administrator mode****************/
int adm()
{
    int x;
	printf("\n\n\n\n");
    printf("\t\t|-------------------------------------------------------------|\n");
    printf("\t\t|                                         |\n");
    printf("\t\t|        ======================        |\n");
    printf("\t\t|               administrator mode                |\n");
    printf("\t\t|        ======================        |\n");
    printf("\t\t|                                         |\n");
    printf("\t\t|           1.Input book information                |\n");
    printf("\t\t|           2.View book information                |\n");
    printf("\t\t|           3.Modify book information                |\n");
    printf("\t\t|           4.Change management password                |\n");
    printf("\t\t|           5.Exit the system                    |\n");
    printf("\t\t|-------------------------------------------------------------|\n");
    printf("\n\t\t Please enter your choice:");
    scanf("%d",&x);
    return x;
}
/******************Customer model********************/
int peo()
{
    int x;
	printf("\n\n\n\n");
    printf("\t\t|-------------------------------------------------------------|\n");
    printf("\t\t|                                         |\n");
    printf("\t\t|        ======================        |\n");
    printf("\t\t|               Welcome                  |\n");
    printf("\t\t|        ======================        |\n");
    printf("\t\t|                                         |\n");
    printf("\t\t|           1.View book information                |\n");
    printf("\t\t|           2.Borrow books                    |\n");
    printf("\t\t|           3.Exit the system                    |\n");
    printf("\t\t|-------------------------------------------------------------|\n");
    printf("\n\t\t Please enter your choice:");
    scanf("%d",&x);
    return x;
}
/*********View all books*******/
void show_all_book()
{
	int i;
	if(bk[0].num==0&&bk[0].t.year==0||N==0)/*When BK [0] num,bk[0].t.year, when the equivalent of the structure array is zero at the same time, it indicates that there is no book information*/
		printf("\t Data does not exist, please enter data first!\n\t\t Press any key to return...");
	else
	{
		printf("\t number    Book name     press        Publication time     state\n");
		for(i=0;i<N;i++)
		{
			printf("\t%-7d %-8s %-12s   %4d year%2d month%2d day ",bk[i].num,bk[i].name,bk[i].publish,bk[i].t.year,bk[i].t.month,bk[i].t.day);
			if(bk[i].jie==0)
				printf("Not borrowed\n");
			else
				printf("Borrowed\n");
		}
	}
}
/*********View by title********/
void showbook_name()
{
    int i,k=0,n;/*k Used to mark whether the book exists*/
    char book_name[20];
    printf("\t\t         =====================        \n");
    printf("\t\t               View by title                \n");
    printf("\t\t         =====================        \n");
    printf("\n\t\t Please enter the name of the book you want to view:");
    scanf("%s",book_name);
    for(i=0;i<N;i++)
        if(strcmp(book_name,bk[i].name)==0)
		{
			n=i;
			if(k==0)/* "Project "output only once"*/
			    printf("\t number    Book name     press        Publication time     state\n");
            printf("\t%-7d %-8s %12s   %4d year%2d month%2d day ",bk[n].num,bk[n].name,bk[n].publish,bk[n].t.year,bk[n].t.month,bk[n].t.day);
		    if(bk[n].jie==1)
                printf("Borrowed\n");
            else
                printf("You can borrow it\n");
	            printf("Press any key to return...");
			k++; /*k A value other than zero indicates that a book was found*/
		}
		if(k==0)  /*k A value of zero indicates that no books were found*/
			printf("\t The book does not exist!Press any key to return...");
}
/*********View by book number********/
void showbook_num()
{
    int n,book_num,i,k=0;/*k Used to mark whether the book exists*/
    printf("\t\t         =====================        \n");
    printf("\t\t               View by book number                \n");
    printf("\t\t         =====================        \n");
    printf("\n\t\t Please enter the book number you want to view:");
    scanf("%d",&book_num);
    for(i=0;i<N;i++)
        if(book_num==bk[i].num)
		{
			n=i;
			if(k==0)/*The project is output only once*/
			    printf("\t number    Book name     press        Publication time     state\n");
            printf("\t%-7d %-8s %12s   %4d year%2d month%2d day ",bk[n].num,bk[n].name,bk[n].publish,bk[n].t.year,bk[n].t.month,bk[n].t.day);
		    if(bk[n].jie==1)
                printf("Borrowed\n");
            else
                printf("You can borrow it\n");
			k++;
			printf("\t Press any key to return...");
		}
	if(k==0) /*k A value of zero indicates that no books were found*/
		printf("\t The book does not exist!Press any key to return...");    	
}

/********Show all borrowed books**********/
void yijieyue()
{
    int i,k=0;
	if(bk[0].num==0&&bk[0].t.year==0||N==0)
		 printf("\t Data does not exist, please enter data first!\n\t\t Press any key to return...");
	else
	{
	    for(i=0;i<N;i++)
			if(bk[i].jie==1)
			{
				if(k==0)
				    printf("\t number    Book name     press        Publication time     \n");
				printf("\t%-7d %-8s %12s   %4d year%2d month%2d day \n",bk[i].num,bk[i].name,bk[i].publish,bk[i].t.year,bk[i].t.month,bk[i].t.day);
                k++;			
			}
            if(k==0)
				printf("\n\t\t There are no books on loan at present. press any key to continue...");
	}
}
/********Show all books not borrowed********/
void weijieyue()
{
    int i,k=0;
	if(bk[0].num==0&&bk[0].t.year==0||N==0)
		 printf("\t Data does not exist, please enter data first!\n\t\t Press any key to return...");
	else
	{
	    for(i=0;i<N;i++)
			if(bk[i].jie==0)
			{
				if(k==0)
				    printf("\t number    Book name     press        Publication time     \n");
				printf("\t%-7d %-8s %12s   %4d year%2d month%2d day \n",bk[i].num,bk[i].name,bk[i].publish,bk[i].t.year,bk[i].t.month,bk[i].t.day);
			    k++;
			}
			if(k==0)
               printf("\n\t unfortunately! All the books have been lent out at present. press any key to continue...");
	}
}
/*****View Book menu******/
void show()
{
    int x;
	do
	{
		 system("cls");
		 printf("\n\n\n\n");
    	 printf("\t\t|-------------------------------------------------------------|\n");
    	 printf("\t\t|                                         |\n");
    	 printf("\t\t|         =====================        |\n");
    	 printf("\t\t|              View book information               |\n");
    	 printf("\t\t|         =====================        |\n");
    	 printf("\t\t|                                         |\n");
    	 printf("\t\t|           1.Search by title                  |\n");
    	 printf("\t\t|           2.Search by book number                  |\n");
    	 printf("\t\t|           3.View all unsold books          |\n");
    	 printf("\t\t|           4.View all borrowed books          |\n");
    	 printf("\t\t|           5.View all books                |\n");
    	 printf("\t\t|           6.Return to main menu                  |\n");
    	 printf("\t\t|-------------------------------------------------------------|\n");
    	 printf("\n\t\t Please enter your choice:");
    	 scanf("%d",&x);
    	 switch(x)
    	 {
         	 case 1:system("cls");showbook_name();getch();break;/*View by title*/
        	 case 2:system("cls");showbook_num();getch();break;/*View by book number*/
       	   	 case 3:system("cls");weijieyue();getch();break;/*View books not borrowed*/
       	   	 case 4:system("cls");yijieyue();getch();break;/*View borrowed books*/
		 	 case 5:system("cls");show_all_book();getch();break;/*View all books*/	
    	 }                                    
	}while(x!=6);
}
/*********Borrow by title*******/
void jie_name()
{
	char jy[2],name[20];/*jy Used to indicate whether to confirm borrowing*/
	int i,book_xb,k=0;/*k Used to mark whether the book exists*/
	printf("\t\t         ======================       \n");
    printf("\t\t                Borrow by title               \n");
    printf("\t\t         ======================       \n");
	while(1)
	{
    printf("\n\t\t Please enter the title of the book:");
    scanf("%s",name);
    for(i=0;i<N;i++)
        if(strcmp(bk[i].name,name)==0&&bk[i].jie!=1)/*Find the book and confirm that the book has not been lent out, and record the book subscript*/
		{
		    book_xb=i;
			k++;
		}
	if(k==0)
	{
		printf("\t The book does not exist or has been lent out!Please input the book name correctly!\n\t\t Press any key to return...");
		getch();
        break;
	}
	if(k==1)
	    printf("\t number    Book name     press        Publication time     state\n");
    printf("\t%-7d %-8s %12s   %4d year%2d month%2d day ",bk[book_xb].num,bk[book_xb].name,bk[book_xb].publish,bk[book_xb].t.year,bk[book_xb].t.month,bk[book_xb].t.day);
    if(bk[book_xb].jie==1)
        printf("Borrowed\n");
    else
        {
           printf("You can borrow it\n\t Borrow it?(Yes:'y',No:'n'): ");
           scanf("%s",jy);
           if(strcmp(jy,"n")==0)
           {
                printf("\t Cancel borrowing, press any key to return....");
                getch();
                break;
           }
           else if(strcmp(jy,"y")==0)
           {
                printf("\t Borrowing succeeded! Press any key to return...");
				bk[book_xb].jie=1;
                getch();
                break;
           }
           else
           {
                printf("\t Wrong input! Press any key to re-enter...");
				getch();
                break;
           }           
		}
	}
}
/*********Borrow by book number*******/
void jie_num()
{
	long i,k=0,book_xb,book_num;/*k Used to mark whether the book exists*/
	char jy[2];/*jy Used to indicate whether to confirm borrowing*/
	printf("\t\t         ======================       \n");
    printf("\t\t                Borrow by book number               \n");
    printf("\t\t         ======================       \n");
    while(1)
	{
    printf("\n\t\t Please enter the book number:");
    scanf("%d",&book_num);
    for(i=0;i<N;i++)
        if(bk[i].num==book_num&&bk[i].jie!=1)
		{
			book_xb=i;
			k++;
		}
        if(k==0)
		{
			printf("\t The book does not exist or has been lent out!Please input the book name correctly!\n\t\t Press any key to return...");
			getch();
            break;
		}
	printf("\t number    Book name     press        Publication time     state\n");
    printf("\t%-7d %-8s %12s   %4d year%2d month%2d day ",bk[book_xb].num,bk[book_xb].name,bk[book_xb].publish,bk[book_xb].t.year,bk[book_xb].t.month,bk[book_xb].t.day);
    if(bk[book_xb].jie==1)
        printf("Borrowed\n");
    else
    {
        printf("You can borrow it\n\t Borrow it?(Yes:'y',No:'n'): ");
        scanf("%s",jy);
        if(strcmp(jy,"n")==0)
        {
             printf("\t Cancel borrowing, press any key to return....");
             getch();
             break;
        }
        else if(strcmp(jy,"y")==0)
        {
             printf("\t Borrowing succeeded! Press any key to return...");
             bk[book_xb].jie=1;
             getch();
             break;
        }
        else
        {
             printf("\t Wrong input! Press any key to re-enter...");
			 getch();
             break;
        }       
    }
	}
}
/*********Borrow books********/
void jieyue()
{
    int x;
    do
    {
    system("cls");
	printf("\n\n\n\n");
    printf("\t\t|-------------------------------------------------------------|\n");
    printf("\t\t|         =====================        |\n");
    printf("\t\t|                Borrow books                 |\n");
    printf("\t\t|         =====================        |\n");
    printf("\t\t|                                         |\n");
    printf("\t\t|            1.Borrow by title                 |\n");
    printf("\t\t|            2.Borrow by book number                 |\n");
    printf("\t\t|            3.View all books               |\n");
    printf("\t\t|            4.Return to main menu                 |\n");
    printf("\t\t|-------------------------------------------------------------|\n");
    printf("\t\t Please enter your choice:");
    scanf("%d",&x);
    switch(x)
    {
        case 1:system("CLS");jie_name();getch();break;/*Borrow by title*/
        case 2:system("CLS");jie_num();getch();break;/*Borrow by book number*/
		case 3:system("cls");show_all_book();getch();break;/*View all books*/
    }
    }while(x!=4);
}
/***************Search by book title and modify information*************/
void xiugai_name()
{
	int i,book_xb,k=0;/*book_xb It is used to record the subscript and k is used to judge whether the book is found*/
	char temp[20];/*temp[20]The title of the book used to store the search entered by the user*/
	while(1)
	{
		system("cls");
		printf("\n");
    	printf("\t\t|         =====================        |\n");
    	printf("\t\t|             Modify by book title              |\n");
    	printf("\t\t|         =====================        |\n");
		printf("\t\t Please enter the name of the book you are going to modify,input'exit'sign out:");
    	scanf("%s",temp);
		if(strcmp(temp,"exit")==0)
		break;
		else
		{
			for(i=0;i<N;i++)
		    if(strcmp(temp,bk[i].name)==0)
			{
				book_xb=i;
			    printf("\t The information in this book is:\n");
			    printf("\t number    Book name     press        Publication time     state\n");
                printf("\t%-7d %-8s %12s   %4d year%2d month%2d day ",bk[book_xb].num,bk[book_xb].name,bk[book_xb].publish,bk[book_xb].t.year,bk[book_xb].t.month,bk[book_xb].t.day);
				if(bk[book_xb].jie==1)
                    printf("Borrowed\n");
                else
                    printf("You can borrow it\n");
				k++;
				printf("\t\t Please enter new information now:\n");
				printf("\t\t Please enter the number of this book:");
                scanf("%d",&bk[book_xb].num);
                printf("\t\t Please enter the name of this book:");
                scanf("%s",bk[book_xb].name);
                printf("\t\t Please enter the publisher of this book:");
                scanf("%s",bk[book_xb].publish);
                printf("\t\t Please enter the publication time of the book(Separated by commas):");
                scanf("%d,%d,%d",&bk[book_xb].t.year,&bk[book_xb].t.month,&bk[book_xb].t.day);
                printf("\t\t Has the book been borrowed,Borrowed input'1',Not borrowed input'0':");
                scanf("%d",&bk[book_xb].jie);
            }
			if(k==0)
			{
				printf("\t The book name you entered does not exist!press any key to continue...");
				getch();
				continue;
			}
			printf("\t congratulations!Information modified successfully!Any key return...");getch();break;
		}
	}
}
/***************Search and modify information by book number*************/
void xiugai_num()
{
	int i,book_xb,k=0;/*book_xb It is used to record the subscript and k is used to judge whether the book is found*/
	long temp;/*temp Used to store the book number entered by the user*/
	do
	{
		system("cls");
	printf("\n");
    printf("\t\t|         =====================        |\n");
    printf("\t\t|             Modify by book number              |\n");
    printf("\t\t|         =====================        |\n");
	printf("\t\t Please enter the book number of the book you are going to modify,input'0'sign out:");
    scanf("%ld",&temp);
	if(temp==0)	break;
	else
	{
		for(i=0;i<N;i++)
		    if(temp==bk[i].num)
			{
				book_xb=i;
			    printf("\t The information in this book is:\n");
			    printf("\t number    Book name     press        Publication time     state\n");
                printf("\t%-7d %-8s %12s   %4d year%2d month%2d day ",bk[book_xb].num,bk[book_xb].name,bk[book_xb].publish,bk[book_xb].t.year,bk[book_xb].t.month,bk[book_xb].t.day);
				k++;
				if(bk[book_xb].jie==1)
                    printf("Borrowed\n");
                else
                    printf("You can borrow it\n");
				printf("Please enter new information now:\n");
				printf("\t\t Please enter the number of this book:");
                scanf("%d",&bk[book_xb].num);
                printf("\t\t Please enter the name of this book:");
                scanf("%s",bk[book_xb].name);
                printf("\t\t Please enter the publisher of this book:");
                scanf("%s",bk[book_xb].publish);
                printf("\t\t Please enter the publication time of the book(Separated by commas):");
                scanf("%d,%d,%d",&bk[book_xb].t.year,&bk[book_xb].t.month,&bk[book_xb].t.day);
                printf("\t\t Has the book been borrowed,Borrowed input'1',Not borrowed input'0':");
                scanf("%d",&bk[book_xb].jie);
            }
			if(k==0)
			{
				printf("\t The book name you entered does not exist!press any key to continue...");
				getch();continue;
			}
			printf("\t congratulations!Information modified successfully!Any key return...");getch();break;
	}
	}while(temp!=0);
}
/**************Delete all books***********/
void dele_all()
{
	char queren[4];
	printf("\t Continuing will delete all information. Do you want to continue?'y'continue,'n'revoke...");
	scanf("%s",queren);
	if(strcmp(queren,"y")==0)
	{
		N=0;
		printf("\t Deleted successfully!\n");
	}
	else
	{
		printf("\t operation canceled by user!Any key return...");
		getch();
	}
}
/******************Delete by title************/
void dele_name()
{
	int i,book_xb,k=0;/*book_xb It is used to store the subscript of the book, and k is used to mark whether the book is found*/
	char queren[4],temp_name[20];/*queren[2]Used to store 'confirm deletion', temp_name[20] used to store the book name entered during search*/
	printf("\t Enter the name of the book you want to delete,input'0'sign out:");
	scanf("%s",temp_name);
	if(strcmp(temp_name,"0")!=0)
	{
	for(i=0;i<N;i++)
	   if(strcmp(temp_name,bk[i].name)==0)
	   {
			book_xb=i;
			printf("\t The information in this book is:\n");
			printf("\t number    Book name     press        Publication time     state\n");
            printf("\t%-7d %-8s %12s   %4d year%2d month%2d day ",bk[book_xb].num,bk[book_xb].name,bk[book_xb].publish,bk[book_xb].t.year,bk[book_xb].t.month,bk[book_xb].t.day);
		    if(bk[i].jie==0)
				printf("Not borrowed\n");
			else
				printf("Borrowed\n");
			k++;
			printf("\t Do you want to delete this book?yes'y',no'n'");
			scanf("%s",queren);
			if(strcmp(queren,"y")==0)
			{
				if(book_xb==N-1)
					N--;
				else
				{
					for(i=0;i<N;i++)
		        		bk[book_xb+i]=bk[book_xb+i+1];
					N--;
				}
		        printf("\t Deleted successfully!\n");
	        }
	        else
	        	printf("\t operation canceled by user!Any key return...");
	    }
	    if(k==0)
	        printf("\t The book was not found,Please check and operate later!,Press any key to return....");getch();
    }	
}
/***************Search and delete by book number***********/
void dele_num()
{
	int i,book_xb,k=0,temp_num;/*book_xb Used to store book subscripts, k to mark whether the book is found, temp_num is used to store the book name entered when searching*/
	char queren[4];/*queren[2]Used to save 'confirm deletion'*/
	while(1)
	{
	printf("\t Enter the book number of the book you want to delete,input'0'sign out:");
	scanf("%d",&temp_num);
	if(temp_num==0)
		break;
	else
	{
	for(i=0;i<N;i++)
	   if(temp_num==bk[i].num)
	   {
			book_xb=i;
			printf("The information in this book is:\n");
			printf("\t number    Book name     press        Publication time     state\n");
            printf("\t%-7d %-8s %12s   %4d year%2d month%2d day ",bk[book_xb].num,bk[book_xb].name,bk[book_xb].publish,bk[book_xb].t.year,bk[book_xb].t.month,bk[book_xb].t.day);
		    if(bk[i].jie==0)
				printf("Not borrowed\n");
			else
				printf("Borrowed\n");
			k++;
			printf("\t Do you want to delete this book?yes'y',no'n'");
			scanf("%s",queren);
			if(strcmp(queren,"y")==0)
			{
				if(book_xb==N-1)
					N--;
				else
				{
					for(i=0;i<N;i++)
		        		bk[book_xb+i]=bk[book_xb+i+1];
					N--;
				}
		        printf("\t Deleted successfully!\n");
	        }
	        else
	        	printf("\t operation canceled by user!Any key return...");
	           }
	        if(k==0)
	        	printf("\t The book was not found,Please check and operate later!,Press any key to return....");getch();break;
       	}	
	}
}
void dele()
{
	int x;	
	do
	{
		system("cls");
		printf("\t\t|-------------------------------------------------------------|\n");
    	printf("\t\t|         =====================        |\n");
    	printf("\t\t|              Delete book information               |\n");
    	printf("\t\t|         =====================        |\n");
    	printf("\t\t|                                         |\n");
    	printf("\t\t|            1.Delete by title                 |\n");
    	printf("\t\t|            2.Delete by book number                 |\n");
    	printf("\t\t|            3.Delete all books               |\n");
    	printf("\t\t|            4.Return to main menu                 |\n");
    	printf("\t\t|-------------------------------------------------------------|\n");
		printf("\t\t Please enter your options:");
		scanf("%d",&x);
		switch(x)
		{
			case 1:system("cls");dele_name();break;
			case 2:system("cls");dele_num();break;
			case 3:system("cls");dele_all();getch();break;
		}
	}while(x!=4);
}

/***************Revise books**************/
void xiugai()
{
    int x;
    do
    {
		system("cls");
		printf("\n\n\n\n");
   	 	printf("\t\t|-------------------------------------------------------------|\n");
   	 	printf("\t\t|         =====================        |\n");
    	printf("\t\t|               Modify book information              |\n");
    	printf("\t\t|         =====================        |\n");
    	printf("\t\t|                                         |\n");
    	printf("\t\t|            1.Search by title                 |\n");
    	printf("\t\t|            2.Search by book number                 |\n");
    	printf("\t\t|            3.Delete book                   |\n");
    	printf("\t\t|            4.Return to main menu                 |\n");
    	printf("\t\t|-------------------------------------------------------------|\n");
    	printf("\t\t Please enter your choice:");
    	scanf("%d",&x);
    	switch(x)
    	{
      	  	case 1:system("CLS");xiugai_name();break;/*Find and modify information by book title*/
      	  	case 2:system("CLS");xiugai_num();break;/*Find and modify information by book number*/
			case 3:system("cls");dele();break;							
    	}
    }while(x!=4);
}

/**************Main function**************/             
void main()
{
    int x,x2,s;/*s Used to judge the result of password verification*/
    do
    {
        system("cls"); x=mymainmenu();
        switch(x)
        {
            case 1:/************Call administrator mode function***********/
				   system("cls");
                   s=mimayanzheng();/*Password verification*/
				   do
				   {				    
						if(s==1)
						{
							system("cls");
							x2=adm();
							switch(x2)
							{
								case 1:system("cls");xinxi();getch();break;/*Input information*/
								case 2:system("cls");show();break;/*see information*/				           
								case 3:system("cls");xiugai();break;/*Modify information*/
								case 4:system("cls");xiugaimima();break;/*Change Password*/
							}	
						}
						else
						{
							printf("\t Wrong password! Press any key to return...");
							getch();
							break;
						}
				   }while(x2!=5);break;
            case 2:/*Call client mode function*/
				  do
				  {
					  system("cls");
					  x2=peo();
					  switch(x2)
					  {
					  case 1:system("cls");show();getch();break;/*View book information*/
					  case 2:system("cls");jieyue();getch();break;/*Borrow books*/
					  }        
				  }while(x2!=3);
        }
    }while(x!=3);
	system("cls");
	printf("\n\n\n\n\n\n\n\n\n\n\n\n\t\t\t\t Thank you for using!\n\t\t\t");
	getch();
}


You can come into one of my study circles [806041599] to study and communicate together. There are some materials that can help you learn better. Any problems you encounter in the process of learning C language can be sent out for discussion. Everyone is learning C/C + +, or changing careers, or college students, as well as front-end parties who want to improve their ability at work, If you are a little partner who is learning C/C + +, you can join the study. Click the link to join the group chat [C language / C + + mutual learning group]

Topics: C C++ data structure Visual Studio