diff --git a/图书管理系统.c b/图书管理系统.c index 01c428f..514604e 100644 --- a/图书管理系统.c +++ b/图书管理系统.c @@ -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