Current location - Recipe Complete Network - Catering franchise - C language source code of commodity inventory management system
C language source code of commodity inventory management system
# 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);