Current location - Training Enrollment Network - Books and materials - Buy book website code
Buy book website code
# include & ltstdio.h & gt

# include & ltstdlib.h & gt

# include & ltconio.h & gt

Structural book

{

int id,usr[ 10],total,store,days[ 10];

Name of person [3 1], author [21];

} books [100];

/* The above is the definition of structure, which is used to store books and borrow books. */

void page_title(char *menu_item)

{

clr SCR();

printf(" & gt; & gt& gt library management system

}

/* The above is the function of printing the header, and the current status can be displayed through the parameter menu_item. */

Voided Return _ Confirm (Voided)

{

Printf ("\ nPress any key to return ... \ n");

getch();

}

/* The above is the function of requesting confirmation before returning, so as to observe the results before returning */

int search_book(void)

{

int n,I;

Printf ("Please enter the book serial number:");

scanf("%d ",& ampI);

for(n = 0; n & lt 100; n++)

{

If (book [n]. id==i)

{

Printf ("Title: %s\n ",books[n]。 Name);

Printf ("Author: %s\n", books[n]. Author);

Printf ("deposit amount: %d, total", books[n]. store);

printf("%d\n ",books[n]。 Total);

Returns n;

}

}

Printf ("\ nBad or invalid book serial number. \ n ");

return- 1;

}

/* The above function is to find the record with the book number matching in the array, display its information and return it.

Returns an array subscript. If the corresponding record cannot be found, an error will be prompted and-1 will be returned. */

Void book_out (void)

{

int n,s,l,d;

Page_title ("borrowing books");

if((n=search_book())! =- 1 & amp; & Books. Store & gt0)

{

Printf ("Please enter the serial number of the library card:");

scanf("%d ",& amps);

Printf ("Please enter the number of loanable days:");

scanf("%d ",& ampd);

for(l = 0; l & lt 10; l++)

{

If (book [n]. usr[l]==0)

{

Books. usr[l]= s;

Books. Days [l] = d;

Break;

}

}

Books. store-;

}

If (n! =- 1 & amp; & Books. All the books are lent out. \ n ");

return _ confirm();

}

/* The above is the function of borrowing books. First call the function of finding books */

Void book_in (void)

{

int n,s,l;

Page_title ("return the book");

if((n=search_book())! =- 1 & amp; & Books. Shop & lt books. Total)

{

Printf ("library card list: \ n");

for(l = 0; l & lt 10; l++)

If (book [n]. usr[l]! =0)

Printf("[%d]-%d days \ n ",books [n]. usr [l],books [n]。 Days [l]);

Printf ("Please enter the serial number of the library card:");

scanf("%d ",& amps);

for(l = 0; l & lt 10; l++)

{

If (book [n]. usr[l]==s)

{

Books. usr[l]= 0;

Books. days[l]= 0;

Break;

}

}

Books. store++;

}

If (n! =- 1 & amp; & Books. Shops = books. Total)

Printf ("It's all in Tibet. \ n ");

return _ confirm();

}

Voided Account Book _ Add (Void)

{

int n;

Page_title ("register a new book");

for(n = 0; n & lt 100; n++)

If (book [n]. id = = 0)break;

Printf ("serial number:");

Scanf("%d ",& books. id);

printf(" Title:");

Scanf("%s ",& books. Name);

Printf ("Author:");

Scanf("%s ",& books. Author);

Printf ("quantity:");

Scanf("%d ",& books. Total);

Books. Shops = books. Total;

return _ confirm();

}

void book_del(void)

{

int n;

Page_title ("cancellation of old books");

if((n=search_book())! =- 1) books [n]. id = 0;

Printf ("This book has been cancelled. \ n ");

return _ confirm();

}

Invalid master (invalid)

{

Menu: page_title ("operation menu");

Printf ("Please use the number keys to select an operation \ n \ n");

Printf(" 1 borrowing books \n2 returning books \ n \ n ");

Printf("3 register new books \n4 cancel old books \ n \ n ");

Printf("\n0 Exit \ 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);

}

Go to the menu;

}

{

int n;

Page_title ("title");

if((n=search_book())! =- 1) books [n]. id = 0;

Printf ("List excellent books? . \ n ");

return _ confirm();

}

Invalid master (invalid)

{

Menu: page_title ("title");

Printf ("\ nSerial number \ n");

printf(" 1 \ nAuthor \ n ");

printf(" 3 \ nQuantity \ n ");

printf(" \ n0 ISBN \ 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);

}

Go to the menu;

}