#include #include #include #include #include #include #include #define BACKSPACE 8 #define PASS_MAXLEN 128 #define LEN sizeof(struct Book) #define LEN1 sizeof(struct reader) void home();//注册总页面 void Reg();//注册 void Log();//登录 void Adm();//管理员 int UserMenu();//用户主页 int AdminMenu();//管理员主页 void BroBook();//借书 void BacBook();//还书 void LooBook(int n);//查询书籍 void AddBook();//添加书籍 void DelBook();//删除书籍 void FixBook();//修改书籍 int Total();//统计书的总数 int Total1();//统计账户总数->用于修改用户名重复的问题 int Total2();//统计读者总数 void SBAut(int q);//图书作者查询 void SBNam(int q);//图书名字查询 void SBCat(int q);//图书分类查询 void ed();//结束 void Reader();//读者借阅信息 void Readername();//按名字查找借阅 void Allreader();//所有查看 ////注册总页面 int main(){ home(); } //建立书籍的结构体 struct Book//图书信息 { char num[20],nam[20],aut[20],pub[20],cat[20]; int many; float price; struct Book *next; }; struct reader//读者信息 { int xuehao; char username[20],time[20],name[20]; struct reader *next; }; void ed(void) { system("cls"); printf("******************************************************************************************\n"); printf("* 图书管理系统(Version 1.0 ) *\n"); printf("******************************************************************************************\n"); printf("* *\n"); printf("* *\n"); printf("* 酱,拜拜咯ヾ(·ω·`)o *\n"); printf("* *\n"); printf("* *\n"); printf("******************************************************************************************\n"); Sleep(1000); system("cls"); home(); } //主页面 void home(){ system("cls"); while(1){ char c; printf("******************************************************************************************\n"); printf("* 图书管理系统(Version 1.0 ) *\n"); printf("******************************************************************************************\n"); printf("* *\n"); printf("* 你好呀,欢迎使用图书管理系统! *\n"); printf("* *\n"); printf("* 请问你想干什么呢? *\n"); printf("* *\n"); printf("* 麻烦按下数字表示您要执行的操作 *\n"); printf("* *\n"); printf("* *\n"); printf("******************************************************************************************\n"); printf("*您是普通用户吗?? * 你是我的Master吗?? *\n"); printf("* * *\n"); printf("* 1.注册用户,和我签订契约吧o(* ̄▽ ̄*)ブ * 3.Master登陆 (*/▽\*) *\n"); printf("* 2.契约签订好了?直接登陆吧 * *\n"); printf("* * *\n"); printf("******************************************************************************************\n\n\n"); printf("\t\t\t\t\t\t\t\t\t您想执行的操作:"); c=getch(); if(c=='1'){ Reg(); break; }else if(c=='2'){ Log(); break; }else if (c=='3'){ Adm(); } system("cls"); } } //注册 void Reg(){ FILE *fp=fopen("账号管理.txt","r"); fp=fopen("账号管理.txt","r"); system("cls"); int k=0; char t; int i=0; char c; char UserName[50],PassWord[10],RePassWord[10]; char name[100],password[100]; printf("\n\n\t\t\t\t\t签订契约\n\n\n"); printf(" 取个好听的名字吧φ(゜▽゜*)/,只能是英文,下划线,数字哦:(按ESC回到登陆界面)\n\n "); while(1){ c=getch(); if(c==27) home(); if(c=='\r'||c=='\n'){ UserName[i]=0; break; } else if(c==8) { if(i==0) i=0; else { printf("\b \b"); i=i-1; } }else if((c<='Z'&&c>='A')||(c<='z'&&c>='a')||(c<='9'&&c>='0')){ UserName[i++]=c; putchar(c); } } printf("\n\n 请输入您的密码,不要随便泄露密码给别人鸭(小声BB)╯ 3╰ :\n\n "); while(1){ int i=0; char c; while(1){ c=getch(); if(c==27) home(); if(c=='\n'||c=='\r'){ PassWord[i]=0; break; } else if(c==BACKSPACE){ PassWord[--i]='\0'; putchar(BACKSPACE); putchar(' '); putchar(BACKSPACE); }//可以用DELETE键 else{ PassWord[i++]=c; putchar('*'); } } i=0; printf("\n\n 确认一下密码QAQ:\n\n "); while(1){ c=getch(); if(c==27) home(); if(c=='\n'||c=='\r'){ RePassWord[i]=0; break; } else if(c==8) { if(i==0) i=0; else { printf("\b \b"); i=i-1; } } else{ RePassWord[i++]=c; putchar('*'); } } system("cls"); printf("\n\n\n"); printf("\t\t\t┌──────────────────────────────────────────────┐\n"); printf("\t\t\t│ │\n"); printf("\t\t\t│ │\n"); printf("\t\t\t│ 注册中. │\n"); printf("\t\t\t│ │\n"); printf("\t\t\t│ │\n"); printf("\t\t\t└──────────────────────────────────────────────┘\n"); Sleep(500); system("cls"); printf("\n\n\n"); printf("\t\t\t┌──────────────────────────────────────────────┐\n"); printf("\t\t\t│ │\n"); printf("\t\t\t│ │\n"); printf("\t\t\t│ 注册中.. │\n"); printf("\t\t\t│ │\n"); printf("\t\t\t│ │\n"); printf("\t\t\t└──────────────────────────────────────────────┘\n"); Sleep(500); system("cls"); printf("\n\n\n"); printf("\t\t\t┌──────────────────────────────────────────────┐\n"); printf("\t\t\t│ │\n"); printf("\t\t\t│ │\n"); printf("\t\t\t│ 注册中... │\n"); printf("\t\t\t│ │\n"); printf("\t\t\t│ │\n"); printf("\t\t\t└──────────────────────────────────────────────┘\n"); Sleep(500); system("cls"); printf("\n\n\n"); printf("\t\t\t┌──────────────────────────────────────────────┐\n"); printf("\t\t\t│ │\n"); printf("\t\t\t│ │\n"); printf("\t\t\t│ 注册中. │\n"); printf("\t\t\t│ │\n"); printf("\t\t\t│ │\n"); printf("\t\t\t└──────────────────────────────────────────────┘\n"); Sleep(500); system("cls"); printf("\n\n\n"); printf("\t\t\t┌──────────────────────────────────────────────┐\n"); printf("\t\t\t│ │\n"); printf("\t\t\t│ │\n"); printf("\t\t\t│ 注册中.. │\n"); printf("\t\t\t│ │\n"); printf("\t\t\t│ │\n"); printf("\t\t\t└──────────────────────────────────────────────┘\n"); Sleep(500); system("cls"); int j=Total1();//一共有j个用户,Total是用来统计文本里面有多少个用户的 for(int i=0;i='A')||(c<='z'&&c>='a')||(c<='9'&&c>='0')){ UserName[i++]=c; putchar(c); } } printf("\n\n 请输入您的密码:\n\n "); i=0; while(1){ c=getch(); if(c==27) home(); if(c=='\r'||c=='\n'){ PassWord[i]=0; break; } else if(c==8) { if(i==0) i=0; else { printf("\b \b"); i=i-1; } } else if((c<='Z'&&c>='A')||(c<='z'&&c>='a')||(c<='9'&&c>='0')){ PassWord[i++]=c; putchar('*'); } } int j=Total1(); system("cls"); printf("\n\n\n"); printf("\t\t\t┌──────────────────────────────────────────────┐\n"); printf("\t\t\t│ │\n"); printf("\t\t\t│ │\n"); printf("\t\t\t│ 登陆中. │\n"); printf("\t\t\t│ │\n"); printf("\t\t\t│ │\n"); printf("\t\t\t└──────────────────────────────────────────────┘\n"); Sleep(500); system("cls"); printf("\n\n\n"); printf("\t\t\t┌──────────────────────────────────────────────┐\n"); printf("\t\t\t│ │\n"); printf("\t\t\t│ │\n"); printf("\t\t\t│ 登陆中.. │\n"); printf("\t\t\t│ │\n"); printf("\t\t\t│ │\n"); printf("\t\t\t└──────────────────────────────────────────────┘\n"); Sleep(500); system("cls"); printf("\n\n\n"); printf("\t\t\t┌──────────────────────────────────────────────┐\n"); printf("\t\t\t│ │\n"); printf("\t\t\t│ │\n"); printf("\t\t\t│ 登陆中... │\n"); printf("\t\t\t│ │\n"); printf("\t\t\t│ │\n"); printf("\t\t\t└──────────────────────────────────────────────┘\n"); Sleep(500); system("cls"); printf("\n\n\n"); printf("\t\t\t┌──────────────────────────────────────────────┐\n"); printf("\t\t\t│ │\n"); printf("\t\t\t│ │\n"); printf("\t\t\t│ 登陆中. │\n"); printf("\t\t\t│ │\n"); printf("\t\t\t│ │\n"); printf("\t\t\t└──────────────────────────────────────────────┘\n"); Sleep(500); system("cls"); printf("\n\n\n"); printf("\t\t\t┌──────────────────────────────────────────────┐\n"); printf("\t\t\t│ │\n"); printf("\t\t\t│ │\n"); printf("\t\t\t│ 登陆中.. │\n"); printf("\t\t\t│ │\n"); printf("\t\t\t│ │\n"); printf("\t\t\t└──────────────────────────────────────────────┘\n"); Sleep(500); system("cls"); for(int f=0;f='A')||(c<='z'&&c>='a')||(c<='9'&&c>='0')){ AdminName[i++]=c; putchar(c); } } printf("\n\n 请输入您的密码:\n\n "); i=0; while(1){ c=getch(); if(c==27) home(); if(c=='\r'||c=='\n'){ PassWord[i]=0; break; } else if(c==8) { if(i==0) i=0; else { printf("\b \b"); i=i-1; } } else if((c<='Z'&&c>='A')||(c<='z'&&c>='a')||(c<='9'&&c>='0')){ PassWord[i++]=c; putchar('*'); } } int j=1; system("cls"); printf("\n\n\n"); printf("\t\t\t┌──────────────────────────────────────────────┐\n"); printf("\t\t\t│ │\n"); printf("\t\t\t│ │\n"); printf("\t\t\t│ 登陆中. │\n"); printf("\t\t\t│ │\n"); printf("\t\t\t│ │\n"); printf("\t\t\t└──────────────────────────────────────────────┘\n"); Sleep(500); system("cls"); printf("\n\n\n"); printf("\t\t\t┌──────────────────────────────────────────────┐\n"); printf("\t\t\t│ │\n"); printf("\t\t\t│ │\n"); printf("\t\t\t│ 登陆中.. │\n"); printf("\t\t\t│ │\n"); printf("\t\t\t│ │\n"); printf("\t\t\t└──────────────────────────────────────────────┘\n"); Sleep(500); system("cls"); printf("\n\n\n"); printf("\t\t\t┌──────────────────────────────────────────────┐\n"); printf("\t\t\t│ │\n"); printf("\t\t\t│ │\n"); printf("\t\t\t│ 登陆中... │\n"); printf("\t\t\t│ │\n"); printf("\t\t\t│ │\n"); printf("\t\t\t└──────────────────────────────────────────────┘\n"); Sleep(500); system("cls"); printf("\n\n\n"); printf("\t\t\t┌──────────────────────────────────────────────┐\n"); printf("\t\t\t│ │\n"); printf("\t\t\t│ │\n"); printf("\t\t\t│ 登陆中. │\n"); printf("\t\t\t│ │\n"); printf("\t\t\t│ │\n"); printf("\t\t\t└──────────────────────────────────────────────┘\n"); Sleep(500); system("cls"); printf("\n\n\n"); printf("\t\t\t┌──────────────────────────────────────────────┐\n"); printf("\t\t\t│ │\n"); printf("\t\t\t│ │\n"); printf("\t\t\t│ 登陆中.. │\n"); printf("\t\t\t│ │\n"); printf("\t\t\t│ │\n"); printf("\t\t\t└──────────────────────────────────────────────┘\n"); Sleep(500); system("cls"); for(int f=0;fnext=p1; p2=p1; p1=(struct Book*)malloc(LEN); } strcpy(p1->num,Num);//复制书号 strcpy(p1->nam,Nam);//复制书名 strcpy(p1->aut,Aut);//复制作者名字 strcpy(p1->pub,Pub);//复制出版社 strcpy(p1->cat,Cat);//复制类别 p1->many=Many;//复制个数 p1->price=Price;//复制单价 } if(n==0){ head=NULL; } else{ p2->next=p1; p1->next=NULL; fclose(fp); } } p=head; for(;p!=NULL;){ if(!strcmp(p->nam,ReName)){ flag=1; k=p->many; (p->many)--; } p=p->next; } if((k>0)&&flag){ fp=fopen("图书.txt","w"); fclose(fp); fp=fopen("图书.txt","a"); p=head; for(;p!=NULL;){ fprintf(fp,"%-8s%-8s%-16s%-16s%-16s%-10d%10.2f\n",p->num,p->nam,p->aut,p->pub,p->cat,p->many,p->price); p=p->next; } free(p); fclose(fp); if((fp1=fopen("读者.txt","r"))==NULL){ fp1=fopen("读者.txt","w"); fclose(fp1); } fp1=fopen("读者.txt","a"); printf("请输入学号:"); scanf("%d",&Xuehao); printf("请输入名字:"); scanf("%s",Mingzi); printf("请输入借书日期(年份/月份/日):"); scanf("%s",Riqi); printf("请输入书名:"); scanf("%s",Shuming); fprintf(fp1,"%-8d%-23s%-18s%-10s\n",Xuehao,Mingzi,Riqi,Shuming); fclose(fp1); printf("借书成功,请按时归还,按Esc键退出\n"); t=getch(); while(t!=27){ t=getch(); continue; } if(t==27){ UserMenu(); } } else{ if(flag!=0){ printf("没有你要的书籍,按Esc键返回\n");// while(t!=27){ t=getch(); continue; } UserMenu(); }else{ printf("库存不足,按Esc键返回\n"); } } while(t!=27){ t=getch(); continue; } UserMenu(); } //还书 void BacBook(){ system("cls"); struct reader *head=NULL; struct Book *zhead=NULL; struct Book *zp,*zp1,*zp2; struct reader *p,*p1,*p2; FILE *fp,*fp1; float Price=0; char t,ReName[100]; int Many; int n=0,j=0,k=0,flag=0,l=0;//k是库存的数量; char Num[20]={'\0'},Aut[20]={'\0'},Pub[20]={'\0'},Nam[20]={'\0'},Cat[20]={'\0'}; int Xuehao,ReXuehao; char Mingzi[20]={'\0'},Riqi[20]={'\0'},Shuming[20]={'\0'}; fp=fopen("读者.txt","r"); if(fp==NULL){ system("cls"); printf("未存在读者文件,请联系管理员\n"); printf("按Esc返回\n"); t=getch(); while(t!=27){ t=getch(); continue; } UserMenu(); }else{ printf("请输入学号:");// scanf("%d",&ReXuehao); printf("请输入姓名:"); scanf("%s",ReName); j=Total2(); for(int i=0;inext=p1; p2=p1; p1=(struct reader*)malloc(LEN1); } p1->xuehao=Xuehao; strcpy(p1->username,Mingzi); strcpy(p1->time,Riqi); strcpy(p1->name,Shuming); } if(n==0){ head=NULL; }else{ p2->next=p1; p1->next=NULL; fclose(fp); } fp=fopen("读者.txt","w"); fclose(fp); fp=fopen("读者.txt","a"); p=head; for(;p!=NULL;){ fprintf(fp,"%-8d%-23s%-18s%-10s\n",p->xuehao,p->username,p->time,p->name); p=p->next; } free(p); fclose(fp); if(flag){ printf("是否确认还书,还书请按回车,退出请按Esc\n"); t=getch(); while(t!=13&&t!=27){ t=getch(); continue; } if(t==27){ printf("正在跳转..."); Sleep(1000); UserMenu(); } printf("还书成功,按Esc键返回"); n=0,flag=0; l=Total(); fp1=fopen("图书.txt","r"); for(int i=0;inext=zp1; zp2=zp1; zp1=(struct Book*)malloc(LEN); } strcpy(zp1->num,Num);//复制书号 strcpy(zp1->nam,Nam);//复制书名 strcpy(zp1->aut,Aut);//复制作者名字 strcpy(zp1->pub,Pub);//复制出版社 strcpy(zp1->cat,Cat);//复制类别 zp1->many=Many;//复制个数 zp1->price=Price;//复制单价 } if(n==0){ zhead=NULL; } else{ zp2->next=zp1; zp1->next=NULL; fclose(fp1); } } zp=zhead; for(;zp!=NULL;){ if(!strcmp(zp->nam,ReName)){ k=zp->many; (zp->many)++; } zp=zp->next; } fp1=fopen("图书.txt","w"); fclose(fp1); fp1=fopen("图书.txt","a"); zp=zhead; for(;zp!=NULL;){ fprintf(fp1,"%-8s%-8s%-16s%-16s%-16s%-10d%10.2f\n",zp->num,zp->nam,zp->aut,zp->pub,zp->cat,zp->many,zp->price); zp=zp->next; } fclose(fp1); t=getch(); while(t!=27){ t=getch(); continue; } if(t==27){ UserMenu(); } else{ system("cls"); printf("不存在这个书,按Esc键返回\n"); while(t!=27){ t=getch(); continue; } if(t==27){ UserMenu(); } } } } } } //看书信息 void LooBook(int n){ system("cls"); while(1){ char t; printf("******************************************************************************************\n"); printf("* 图书管理系统(Version 1.0 ) *\n"); printf("******************************************************************************************\n"); printf("* *\n"); printf("* 搜索方式: *\n"); printf("* *\n"); printf("* 1、按书名查找 *\n"); printf("* *\n"); printf("* 2、按作者查找 *\n"); printf("* *\n"); printf("* 3、按分类查找 *\n"); printf("* *\n"); printf("* 按ESC返回 *\n"); printf("******************************************************************************************\n"); printf("\n\n\t\t\t\t\t\t\t\t\t您想执行的操作:"); t=getch(); while(t!='1'&&t!='2'&&t!='3'&&t!=27){ t=getch(); continue; } if(t=='1'){ SBNam(n); break; }else if(t=='2'){ SBAut(n); break; }else if(t=='3'){ SBCat(n); break; }else if(t==27){ if(n==0){ UserMenu(); }else if(n==1){ AdminMenu(); } break; } } } void SBAut(int q){ system("cls"); struct Book *head; struct Book *p1,*p2; FILE *fp; int n=0; int m=0,Many=0; float Price=0; char t,ReName[100]; int i=0,k=0,j=0; char Num[20]={'\0'},Aut[20]={'\0'},Pub[20]={'\0'},Nam[20]={'\0'},Cat[20]={'\0'}; if((fp=fopen("图书.txt","r"))==NULL){ printf("无法打开该文件\n"); printf("按ESC键返回\n"); t=getch(); while(t!=27){ t=getch(); continue; } UserMenu(); } else{ printf("请输入你想要查找书的作者名字:\n"); scanf("%s",ReName); j=Total(); for(int i=0;inext =p1; p2=p1; p1=(struct Book*)malloc(LEN); } strcpy(p1->num,Num);//复制书号 strcpy(p1->nam,Nam);//复制书名 strcpy(p1->aut,Aut);//复制作者名字 strcpy(p1->pub,Pub);//复制出版社 strcpy(p1->cat,Cat);//复制类别 p1->many=Many;//复制个数 p1->price=Price;//复制单价 } } if(n==0){ head=NULL; }else{ p2->next=p1; p1->next=NULL; fclose(fp); } } fp=fopen("图书.txt","w"); fclose(fp); fp=fopen("图书.txt","a"); p=head; for(;p!=NULL;){ fprintf(fp,"%-8s%-9s%-14s%-16s%-18s%-7d%-8.2f\n",p->num,p->nam,p->aut,p->pub,p->cat,p->many,p->price); p=p->next; } fclose(fp); system("cls"); printf("删除成功,按任意键返回上一层\n"); t=getch(); AdminMenu(); } //修改书籍 void FixBook(){ system("cls"); struct Book *head,*p1,*p2,*p; int i,n; char Rename[100]; char Num[20],Nam[20],Aut[20],Pub[20],Cat[20]; int Many; float Price; printf("请输入您要修改图书的书名:"); scanf("%s",Rename); FILE *fp; fp = fopen("图书.txt","r"); n = Total(); int count=0; int k=0; for(i=0;inext=p1; p2=p1; p1=(struct Book*)malloc(LEN); } strcpy(p1->num,Num);//复制书号 strcpy(p1->nam,Nam);//复制书名 strcpy(p1->aut,Aut);//复制作者名字 strcpy(p1->pub,Pub);//复制出版社 strcpy(p1->cat,Cat);//复制类别 p1->many=Many;//复制个数 p1->price=Price;//复制单价 } } if(n==0){ head = NULL; } else{ p2->next=p1; p1->next=NULL; fclose(fp); } fp=fopen("图书.txt","w"); fclose(fp); fp=fopen("图书.txt","a"); p=head; for(;p!=NULL;){ fprintf(fp,"%-8s%-9s%-14s%-16s%-18s%-7d%-8.2f\n",p->num,p->nam,p->aut,p->pub,p->cat,p->many,p->price); p=p->next; } fclose(fp); fp = fopen("图书.txt","a"); system("cls"); printf("请输入书号:");scanf("%s",Num); printf("请输入书名:");scanf("%s",Nam); printf("请输入作者:");scanf("%s",Aut); printf("请输入出版社:");scanf("%s",Pub); printf("请输入图书类别:");scanf("%s",Cat); printf("请输入图书数量:");scanf("%d",&Many); printf("请输入图书价格(最多两位小数):");scanf("%f",&Price); fprintf(fp,"%-8s%-9s%-14s%-16s%-18s%-7d%-8.2f\n",Num,Nam,Aut,Pub,Cat,Many,Price); system("cls"); printf("\n\n\n"); printf("\t\t\t┌──────────────────────────────────────────────┐\n"); printf("\t\t\t│ │\n"); printf("\t\t\t│ │\n"); printf("\t\t\t│ 正在写入图书信息. │\n"); printf("\t\t\t│ │\n"); printf("\t\t\t│ │\n"); printf("\t\t\t└──────────────────────────────────────────────┘\n"); Sleep(500); system("cls"); printf("\n\n\n"); printf("\t\t\t┌──────────────────────────────────────────────┐\n"); printf("\t\t\t│ │\n"); printf("\t\t\t│ │\n"); printf("\t\t\t│ 正在写入图书信息.. │\n"); printf("\t\t\t│ │\n"); printf("\t\t\t│ │\n"); printf("\t\t\t└──────────────────────────────────────────────┘\n"); Sleep(500); system("cls"); printf("\n\n\n"); printf("\t\t\t┌──────────────────────────────────────────────┐\n"); printf("\t\t\t│ │\n"); printf("\t\t\t│ │\n"); printf("\t\t\t│ 正在写入图书信息... │\n"); printf("\t\t\t│ │\n"); printf("\t\t\t│ │\n"); printf("\t\t\t└──────────────────────────────────────────────┘\n"); Sleep(500); system("cls"); printf("\n\n\n"); printf("\t\t\t┌──────────────────────────────────────────────┐\n"); printf("\t\t\t│ │\n"); printf("\t\t\t│ │\n"); printf("\t\t\t│ 正在写入图书信息. │\n"); printf("\t\t\t│ │\n"); printf("\t\t\t│ │\n"); printf("\t\t\t└──────────────────────────────────────────────┘\n"); Sleep(500); system("cls"); printf("\n\n\n"); printf("\t\t\t┌──────────────────────────────────────────────┐\n"); printf("\t\t\t│ │\n"); printf("\t\t\t│ │\n"); printf("\t\t\t│ 正在写入图书信息.. │\n"); printf("\t\t\t│ │\n"); printf("\t\t\t│ │\n"); printf("\t\t\t└──────────────────────────────────────────────┘\n"); Sleep(500); system("cls"); printf("\n\n\n"); printf("\t\t\t┌──────────────────────────────────────────────┐\n"); printf("\t\t\t│ │\n"); printf("\t\t\t│ 操作成功,是否要继续? │\n"); printf("\t\t\t│ │\n"); printf("\t\t\t├───────────────────────┬──────────────────────│\n"); printf("\t\t\t│ 1.是 │ 2.否 │\n"); printf("\t\t\t└───────────────────────┴ ─────────────────────┘\n"); fclose(fp); char t; while(1) //利用死循环可有效防止其他按键干扰 { t=getch(); if(t=='1') AddBook(); else if(t=='2') AdminMenu(); } } //统计图书数量 int Total(){ 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("图书.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 Total1(){ int n; char name[100],password[100]; FILE *fp=fopen("账号管理.txt","r"); for(n=0;!feof(fp);n++){ fscanf(fp,"%s%s",name,password); } n--; fclose(fp); return (n); } //统计读者数量 int Total2(){ int n; int num; char username[20],time[20],name[20]; FILE *fp=fopen("读者.txt","r"); for(n=0;!feof(fp);n++){ fscanf(fp,"%d%s%s%s",&num,username,time,name); } n--; fclose(fp); return (n); } void Reader() { system("cls"); printf("******************************************************************************************\n"); printf("* 图书管理系统(Version 1.0 ) *\n"); printf("******************************************************************************************\n"); printf("* *\n"); printf("* 搜索方式: *\n"); printf("* *\n"); printf("* 1、按账号查找 *\n"); printf("* *\n"); printf("* 2、所有借书总览 *\n"); printf("* *\n"); printf("* 按ESC返回 *\n"); printf("******************************************************************************************\n"); printf("\n\n\t\t\t\t\t\t\t\t\t您想执行的操作:"); char op; while(1) { op = getch(); if(op=='1') Readername(); else if(op=='2') Allreader(); else if(op==27) AdminMenu(); } } void Readername() { system("cls"); printf("您想查看的读者的名字:"); char Name[100]; char username[100],time[100],name[100]; int num; scanf("%s",Name); FILE *fp; fp = fopen("读者.txt","r"); int n = Total2(); int i;int count=0; for(i=0;i