在这#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>
#include <math.h>
#define LEN sizeof(struct book)
#define LEN1 sizeof(struct reader)
#define LEN2 sizeof(struct land)
struct book
{
char num[20],nam[20],aut[20],pub[20],cat[20];
int many;
float price;
struct book*next;
};
struct reader
{
int jnum;
char jnam[20],time[20],tsnam[20];
struct reader *next;
};
struct land
{
int zhanghao;
char password[20];
struct land*next;
};
int tjzs();
void xg(int,char[] );
void mainmenu();
void tsmenu();
void jmenu();
void lmenu();
void main1();
void tsmain();
void cxts();
void zjts();
void scts();
void llts();
void jmain();
void js();
void hs();
void cxjs();
void lljs();
void land();
int xinjian(int,char[] );
void xgmm();
void lmain();
int tjzs()
{
FILE *fp;
int txcl=0,n;
float tprice=0;
char tname[20]={
'\0'},tauthor[20]={
'\0'},tchuban[20]={
'\0'},tkind[20]={
'\0'},tshuhao[20]={
'\0'};
fp=fopen("library.txt","r");
for (n=0;!feof(fp);n++)
fscanf(fp,"%s%s%s%s%s%d%f",tshuhao,tname,tauthor,tchuban,tkind,&txcl,&tprice);
n--;
fclose(fp);
return (n);
}
int tjdzzs()
{
FILE *fp;
int zhenghao=0,n;
char mingzi[20]={
'\0'},riqi[20]={
'\0'},zname[20]={
'\0'};
fp=fopen("reader.txt","r");
for (n=0;!feof(fp);n++)
fscanf(fp,"%d%s%s%s ",&zhenghao,&mingzi,&riqi,&zname);
n--;
fclose(fp);
return (n);
}
int tjzs3()
{
FILE *fp;
int zhao=0,n;
char mm[20]={
'\0'};
fp=fopen("land.txt","r");
for (n=0;!feof(fp);n++)
fscanf(fp,"%d %s",&zhao,mm);
n--;
fclose(fp);
return (n);
}
void mainmenu()
{
system ("cls");
printf("**************************************************");
printf("\n\n 1.图书系统\n\n");
printf("\n\n 2.借阅系统\n\n");
printf("\n\n 3.退出系统\n\n");
printf("\n\n 请按键选择,回车确定\n");
printf("*************************************************\n");
return ;
}
void tsmenu()
{
system ("cls");
printf("****************************************************");
printf("\n 1.增加图书\n\n");
printf("\n 2.删除图书\n\n");
printf("\n 3.查询图书\n\n");
printf("\n 4.库存浏览\n\n");
printf("\n 5.返回上一层\n\n");
printf("\n 请按键选择,回车确定\n");
printf("***************************************************\n");
return ;
}
void main1()
{
void tsmian();
void jmain();
char choose;
mainmenu();
scanf(" %c",&choose);
switch(choose)
{
case'1':
tsmain();
break;
case'2':
jmain();
break;
case'3':
system("cls");
getch();
exit(0);
system ("cls");
break;
}
}
void tsmain()
{
void zjts();
void scts();
void ctts();
void llts();
char choose;
tsmenu();
scanf(" %c",&choose);
for(;;)
{
switch(choose)
{
case'1':
zjts();
break;
case'2':
scts();
break;
case'3':
cxts();
break;
case'4':
llts();
break;
case'5':
main1();
break;
}
}
}
void zjts()
{
FILE*fp;
char i;
int many=0;
float price=0;
char nam[20]={
'\0'},aut[20]={
'\0'},cat[20]={
'\0'},pub[20]={
'\0'},num[20]={
'\0'};
system ("cls");
if ((fp=fopen("library.txt","r"))==NULL)
{
fp=fopen("library.txt","w");
fclose(fp);
}
fp=fopen("library.txt","a");
printf("\n请按以下格式输入图书信息:\n书号 书名 作者 出版社 类别 进库量 单价");
for(;i!=27;)
{
printf("请输入:\n");
scanf("%s%s%s%s%s%d%f",num,nam,aut,pub,cat,&many,&price);
fprintf(fp,"%-8s%-9s%-14s%-16s%-18s%-7d%-8.2f\n",num,nam,aut,pub,cat,many,price);
printf("继续输入请按回车,结束输入请按Esc\n");
i=getch();
for (;i!=13&&i!=27;)
i=getch();
}
fclose(fp);
printf("\n保存成功,按任意键返回上一层!");
getch();
tsmain();
}
void scts()
{
struct book *head=NULL;
struct book *p,*p1,*p2;
int tmany=0,n=0,j,k;
float tprice=0;
char tnam[20]={
'\0'},taut[20]={
'\0'},tcat[20]={
'\0'},tpub[20]={
'\0'},tnum[20]={
'\0'};
char jjnam[20]={
'\0'};
char i;
FILE *fp;
if ((fp=fopen("library.txt","r"))==NULL)
{
system ("cls");
printf("\n记录文件不存在!按任意键返回");
getch();
tsmain();
}
else
{
system ("cls");
printf("\n请输入你要删除的书名:");
scanf("%s",jjnam);
printf("\n确认删除请回车,取消请按Esc\n");
i=getch();
for(;i!=13&&i!=27;)
i=getch()