#include "bookrecord.h"
void search( BOOK *top){
char choose[25],input[30];
int cn=0;
BOOK *p;
ASK(p);
for(;;)
{
if(count==0)
{
printf("这是空表,还没有记录!\n");
return ;
}
printf("1.通过出版社\n");
printf("2.通过主编\n");
printf("3.通过书名\n");
printf("请选择1-3:\n");
gets(choose);
while(1)
{
cn=atoi(choose);
if(cn<0||cn>3)
{
printf("输入错误,重新选择1-3:");
gets(choose);
}
else break;
}
switch(cn)
{
case 1:
printf("请输入出版社:");
break;
case 2:
printf("请输入主编:");
break;
case 3:
printf("请输入书名:");
break;
}
gets(input);
p=top;
while(p!=NULL)
{
if((cn==1&&strcmp(input,p->press)==0)||(cn==2&&strcmp(input,p->author_name)==0)||(cn==3&&strcmp(input,p->name)==0))
{
if(p==top)
{
printf("author_name\t press\t year\t edition\t name\t ISBN\t price\t total\t lend\t left\n");
printf("%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n",p->author_name,p->press,p->year,p->edition,p->name,p->ISBN,p->price,p->total,p->lend,p->left);
break;
}
else
{
p=p->next;
if(p==NULL)break;
}
if(p==NULL)
{
printf("你所查询的书没找到!\n");
}
else
{
printf("找到了如下信息:");
}
printf("author_name\t press\t year\t edition\t name\t ISBN\t price\t total\t lend\t left\n");
printf("%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n",p->author_name,p->press,p->year,p->edition,p->name,p->ISBN,p->price,p->total,p->lend,p->left);
}
}
}
}