/*******************************************************/
/* 函数功能:结点删除 */
/* 输入参数:链表头指针 */
/* 函数输出:返回链表头指针 */
/*******************************************************/
struct node *del(struct node *head)
{
char sn[15],s;
int m=0;
struct node *p,*q;
window(3,3,40,20);
gotoxy(3,m++);
cprintf("Please input book name\n");
gotoxy(3,m++);
cprintf("\nname:");scanf("%s",sn);
p=head;
while((p!=NULL) && (strcmp(p->name,sn)!=0))
{ q=p;p=p->link;}
if(strcmp(p->name,sn)==0)
{
gotoxy(3,m++);
cprintf(" name price publshier\n");
gotoxy(3,m++);
cprintf("Book Found: %s %5.2f %s\n",p->name,p->price,p->pub);
gotoxy(3,m++);
cprintf("Do you want to del this book(y/n)");
scanf("\n%c",&s);
if(s=='y' || s=='Y')
{
if(p==head)head=p->link;
else q->link=p->link;
gotoxy(3,m++);
cprintf("This book is deleted!\n");
gotoxy(3,m++);
cprintf("\n Press any keys !");getch();
return head;
}
else
{
gotoxy(3,m++);
cprintf("\nThis book not delete!\n");
}
}
else
{
gotoxy(3,m++);
cprintf("NOT found!");
}
gotoxy(3,m++);
cprintf("\n Press any keys!");getch();
return head;