#include<stdio.h>#include<windows.h>#include<string.h>#include<conio.h>#define M 100struct books{char tsmc[12];int tsbh;float dj;char zz[12];char czzt[12];char xm[12];char xb[12];int xh; }s[M];int N;bool flag;intmain (){int sele;flag=0;sele=1;void sr();void cx();void sc();void js();void hs();void tc();void jsh();//system ("tsgl");printf("\n\n");printf(" ************************\n");printf(" 1:输入2:查询3:删除\n");printf(" 4:借书5:还书0:退出\n");printf(" ************************\n"); while(1){printf("\n\n请输入功能序号:");scanf ("%d",&sele);if(sele>=0 && sele<=5){switch(sele){ case 1:sr();break;case 2:cx();break;case 3:sc();break;case 4:js();break;case 5:hs();break;case 0:jsh();break;}if(flag)break;printf("\n\n");printf(" ************************\n");printf(" 1:输入2:查询3:删除\n");printf(" 4:借书5:还书0:退出\n");printf(" ************************\n");}else{printf("输入错误请再次输入|\n\n");printf("\n\n");printf(" ************************\n");printf(" 1:输入2:查询3:删除\n");printf(" 4:借书5:还书0:退出\n");printf(" ************************\n");}printf("\n\n让任意键继续\n");} //wr_file();} /******主函数***//*********输入*********/void sr(){int n,i;N=0;printf("可输入的书本数:");scanf("%d",&n);N=n+N;printf("请输入相关信息:\n");for(i=1;i<=n;i++){printf("图书名称:");scanf("%s",s[N-n-1+i].tsmc);printf("图书编号:");scanf("%d",&s[N-n-1+i].tsbh);printf("单价:");scanf("%f",&s[N-n-1+i].dj);printf("作者:");scanf("%s",&s[N-n-1+i].zz);strcpy(s[N-n-1+i].czzt,"未借出");strcpy(s[N-n-1+i].xm,"无"); } }/********查询**********/void cx(){int i,j[100]={-1},d,k,t=0;char m[20];printf("查询:");printf("1:图书名称2:图书编号");printf("\n\n请输入查询选项:");scanf("%d",&k);if(k==1){printf("请输入图书名称:");scanf("%s",m);for(i=0;i<N;i++)if(strcmp(m,s[i].tsmc)==0){j[t]=i;t=t+1;}}else if(k==2){printf("请输入图书编号:");scanf("%d",&d);for(i=0;i<N;i++)if(d==s[i].tsbh){j[t]=i;t++;}}if(j[0]==-1&&t==0)printf("没有找到!\n");if(j[0]!=-1 && t!=0){printf("\t图书名称\t图书编号\t单价\t作者\t存在状态\t借书人姓名\t性别\t学号\n");for(i=0;i<t;i++)printf("\t%s \t%d \t%f \t%s \t%s \t%s \t%s \t%d ", s[j[i]].tsmc,s[j[i]].tsbh,s[j[i]].dj,s[j[i]].zz,s[j[i]].czzt,s[j[i]].xm,s[j[i]].xb,s[j[i]].xh);}}/********删除模块*********/void sc(){int i,d,k,t=0;char ms[20];int ja=-1;printf("查询:");printf("1:图书名称2:图书编号");printf("\n\n请输入查询选项:");scanf("%d",&k);if(k==1){printf("请输入图书名称:");scanf("%s",ms);for(i=0;i<N;i++)if(strcmp(ms,s[i].tsmc)==0){ja=i; break;}}else if(k==2){printf("请输入图书编号:");scanf("%d",&d);for(i=0;i<N;i++)if(d==s[i].tsbh){ja=i;break;}}printf("确定删除该图书吗?1表示Yes,其他No");int p;scanf("%d",&p);if(p==1)printf("Congratulations,删除成功||\n");if(ja!=-1 && p){N=N-1;for(i=ja;i<N;i++){strcpy(s[i].tsmc,s[i+1].tsmc);s[i].tsbh=s[i+1].tsbh;s[i].dj=s[i+1].dj;strcpy(s[i].zz,s[i+1].zz);strcpy(s[i].czzt,s[i+1].czzt);strcpy(s[i].xm,s[i+1].xm);strcpy(s[i].xb,s[i+1].xb);s[i].xh=s[i+1].xh;}}else if(ja==-1)printf ("没有找到!\n"); }/**********借书模块***********/void js(){int i,j[100]={-1},d,k,t=0;char m[20];printf("查询:");printf("1:图书名称2:图书编号");printf("\n\n请输入查询选项:");scanf("%d",&k); if(k==1){printf("请输入图书名称:");scanf("%s",&m);for(i=0;i<N;i++)if(strcmp(m,s[i].tsmc)==0){j[t]=i;t=t+1;}}else if(k==2){printf("请输入图书编号:");scanf("%d",&d);for(i=0;i<N;i++)if(d==s[i].tsbh){j[t]=i;t++;}}if(j[0]==-1&&t==0)printf("没有找到!\n");strcpy(s[j[i]].czzt,"已借出");printf("此书已借出\n");if(j[0]!=-1&&t!=0&&s[j[i]].czzt==" 未借出"){printf("%s %d %f %s %s %s %s %d ", s[j[i]].tsmc,s[j[i]].tsbh,s[j[i]].dj,s[j[i]].zz,s[j[i]].czzt,s[j[i]].xm,s[j[i]].xb,s[j[i]].xh); }printf("1:确定借阅2:退出\n");scanf("%d",&k);switch(k){case 1:printf("请输入学号:\n");scanf("%d",&s[j[i]].xh);printf("请输入姓名:\n");scanf("%s",&s[j[i]].xm);printf("请输入性别:\n");scanf("%s",&s[j[i]].xb);strcpy(s[j[i]].czzt,"已借出");printf("已借出,按任意键继续\n");//getch();case 2:break;}}/*************还书模块***************/void hs(){int i,j[100]={-1},d,k,t=0;char m[20];printf("查询:");printf("1:图书名称2:图书编号");printf("\n\n请输入查询选项:");scanf("%d",&k);if(k==1){printf("请输入图书名称:");scanf("%s",&m);for(i=0;i<N;i++)if(strcmp(m,s[i].tsmc)==0){j[t]=i;t++;break;}}else if(k==2){printf("请输入图书编号:");scanf("%d",&d);for(i=0;i<N;i++)if(d==s[i].tsbh){j[t]=i;t++;break;}}if(t==0)printf("没有找到!\n");else{printf("%s %f %s %s %s %s %d \n",s[j[i]].tsmc,s[j[i]].dj,s[j[i]].zz,s[j[i]].czzt,s[j[i]].xm,s[j[i]].xb,s[j[i]].xh);printf("1:确定归还2:退出\n");int p;scanf("%d",&p);if(p==1){strcpy(s[j[i]].czzt,"未借出");strcpy(s[j[i]].xm,"无");s[j[i]].xh=0;printf("已归还,按任意键继续\n");}//getch();}}/*************结束模块***************/void jsh(){flag=1;}。