Merge pull request 'C5' (#7) from C5 into master

6-9
mac76tib2 2 years ago
commit b438b604b3

@ -174,7 +174,39 @@ Book* AddBook(Book* book1)
return;
}
//C5
Book* DealoldBook(Book* book1)
{
Book* book = book1;
Book* prev = book1;
printf("输入要处理旧书的编号:");
int id;
scanf("%d", &id);
getchar();
while (book != NULL)
{
if (id == book->iNum)
{
if (book1 == book)
{
book = book->next;
free(prev);
return book;
}
prev->next = book->next;
free(book); // free():释放资源
printf("已将旧书处理掉!\n");
printf("按任意键返回\n");
getchar();
return book1;
}
prev = book;
book = book->next;
}
printf("没有找到该图书\n");
printf("按任意键返回\n");
getchar();
return book1;
}
//C6
//C7

Loading…
Cancel
Save