#includestdio.h#includewindows.h#includestring.h#includeconio.h#defineM100structbooks{chartsmc[12];inttsbh;floatdj;charzz[12];charczzt[12];charxm[12];charxb[12];intxh;}s[M];intN;boolflag;intmain(){intsele;flag=0;sele=1;voidsr();voidcx();voidsc();voidjs();voidhs();voidtc();voidjsh();//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){case1:sr();break;case2:cx();break;case3:sc();break;case4:js();break;case5:hs();break;case0: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();}/******主函数***//*********输入*********/voidsr(){intn,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,无);}}/********查询**********/voidcx(){inti,j[100]={-1},d,k,t=0;charm[20];printf(查询:);printf(1:图书名称2:图书编号);printf(\n\n请输入查询选项:);scanf(%d,&k);if(k==1){printf(请输入图书名称:);scanf(%s,m);for(i=0;iN;i++)if(strcmp(m,s[i].tsmc)==0){j[t]=i;t=t+1;}}elseif(k==2){printf(请输入图书编号:);scanf(%d,&d);for(i=0;iN;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;it;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);}}/********删除模块*********/voidsc(){inti,d,k,t=0;charms[20];intja=-1;printf(查询:);printf(1:图书名称2:图书编号);printf(\n\n请输入查询选项:);scanf(%d,&k);if(k==1){printf(请输入图书名称:);scanf(%s,ms);for(i=0;iN;i++)if(strcmp(ms,s[i].tsmc)==0){ja=i;break;}}elseif(k==2){printf(请输入图书编号:);scanf(%d,&d);for(i=0;iN;i++)if(d==s[i].tsbh){ja=i;break;}}printf(确定删除该图书吗?1表示Yes,其他No);intp;scanf(%d,&p);if(p==1)printf(Congratulations,删除成功||\n);if(ja!=-1&&p){N=N-1;for(i=ja;iN;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;}}elseif(ja==-1)printf(没有找到!\n);}/**********借书模块***********/voidjs(){inti,j[100]={-1},d,k,t=0;charm[20];printf(查询:);printf(1:图书名称2:图书编号);printf(\n\n请输入查询选项:);scanf(%d,&k);if(k==1){printf(请输入图书名称:);scanf(%s,&m);for(i=0;iN;i++)if(strcmp(m,s[i].tsmc)==0){j[t]=i;t=t+1;}}elseif(k==2){printf(请输入图书编号:);scanf(%d,&d);for(i=0;iN;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){case1: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();case2:break;}}/*************还书模块***************/voidhs(){inti,j[100]={-1},d,k,t=0;charm[20];printf(查询:);printf(1:图书名称2:图书编号);printf(\n\n请输入查询选项:);scanf(%d,&k);if(k==1){printf(请输入图书名称:);scanf(%s,&m);for(i=0;iN;i++)if(strcmp(m,s[i].tsmc)==0){j[t]=i;t++;break;}}elseif(k==2){printf(请输入图书编号:);scanf(%d,&d);for(i=0;iN;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);intp;scanf(%d,&p);if(p==1){strcpy(s[j[i]].czzt,未借出);strcpy(s[j[i]].xm,无);s[j[i]].xh=0;printf(已归还,按任意键继续\n);}//getch();}}/*************结束模块***************/voidjsh(){flag=1;}