为什么我的查找功能不能实现,哪里出错了?
函数如下:
/step6. findFindByISBN
LNode* FindByISBNInList(BookList booklist, string isbn)
{
LNode* p = booklist->front;
while (p != NULL && p->data.isbn!=isbn)
{
p = p->next;
}
printBook(p->data);
}
//findBybookname
LNode* FindByBooknameInList(BookList booklist, string bookname)
{
LNode* p = booklist->front;
while (p != NULL && p->data.name != bookname)
{
p = p->next;
}
printBook(p->data);
}
//findBybookprice
LNode* FindByBookpriceInList(BookList booklist, double bookprice)
{
LNode* p = booklist->front;
while (p != NULL && p->data.price != bookprice)
{
p = p->next;
}
printBook(p->data);
}
调用:
int b;
string name;
string isbn1,isbn;
double price;
PrintBookList(booklist);
printf("请选选择要修改的书的isbn:\n");
cin>>isbn;
printf("请选择要修改的内容:1.书名 2.isbn 3.价格\n");
cin>>b;
LNode* node = FindByISBNInList(booklist,isbn);
if(b==1)
cout<<"请输入书名:\n";
cin>>name;
ModifyByBookname(node,name);
break;
if(b==2)
cout<<"请输入isbn:\n";
cin>>isbn1;
ModifyByBookisbn(node,isbn1);
break;
if(b==3)
cout<<"请输入价格:\n";
cin>>price;
ModifyByBookprice(node,price);
break;
函数如下:
/step6. findFindByISBN
LNode* FindByISBNInList(BookList booklist, string isbn)
{
LNode* p = booklist->front;
while (p != NULL && p->data.isbn!=isbn)
{
p = p->next;
}
printBook(p->data);
}
//findBybookname
LNode* FindByBooknameInList(BookList booklist, string bookname)
{
LNode* p = booklist->front;
while (p != NULL && p->data.name != bookname)
{
p = p->next;
}
printBook(p->data);
}
//findBybookprice
LNode* FindByBookpriceInList(BookList booklist, double bookprice)
{
LNode* p = booklist->front;
while (p != NULL && p->data.price != bookprice)
{
p = p->next;
}
printBook(p->data);
}
调用:
int b;
string name;
string isbn1,isbn;
double price;
PrintBookList(booklist);
printf("请选选择要修改的书的isbn:\n");
cin>>isbn;
printf("请选择要修改的内容:1.书名 2.isbn 3.价格\n");
cin>>b;
LNode* node = FindByISBNInList(booklist,isbn);
if(b==1)
cout<<"请输入书名:\n";
cin>>name;
ModifyByBookname(node,name);
break;
if(b==2)
cout<<"请输入isbn:\n";
cin>>isbn1;
ModifyByBookisbn(node,isbn1);
break;
if(b==3)
cout<<"请输入价格:\n";
cin>>price;
ModifyByBookprice(node,price);
break;