|
|
|
@ -241,23 +241,128 @@ Book* AddBook(Book* book1)
|
|
|
|
|
//旧书处理
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//根据书名检索书刊信息
|
|
|
|
|
void foundBook(Book* book1)
|
|
|
|
|
{
|
|
|
|
|
Book* book = book1;
|
|
|
|
|
printf("输入要查找的书的id:");
|
|
|
|
|
int id;
|
|
|
|
|
scanf("%d", &id);
|
|
|
|
|
getchar();
|
|
|
|
|
while (book != NULL)
|
|
|
|
|
{
|
|
|
|
|
if (id == book->iNum)
|
|
|
|
|
{
|
|
|
|
|
printf("该书的信息如下:\n");
|
|
|
|
|
printf("%d\t%s\t%s\t%s\t%d\n", book->iNum, book->acName, book->acAuthor, book->acPress, book->iAmount);
|
|
|
|
|
printf("按任意键返回\n");
|
|
|
|
|
getchar();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
book = book->next;
|
|
|
|
|
}
|
|
|
|
|
printf("没有找到该书!\n");
|
|
|
|
|
printf("按任意键返回\n");
|
|
|
|
|
getchar();
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
//查询读者的借阅信息
|
|
|
|
|
void foundReader_Info(Reader* reader1)
|
|
|
|
|
{
|
|
|
|
|
Reader* reader = reader1; //备份
|
|
|
|
|
printf("输入读者的id:");
|
|
|
|
|
int id;
|
|
|
|
|
scanf("%d", &id);
|
|
|
|
|
getchar();
|
|
|
|
|
while (reader)
|
|
|
|
|
{
|
|
|
|
|
if (id == reader->iNum)
|
|
|
|
|
{
|
|
|
|
|
printf("借阅的书的编号如下:\n");
|
|
|
|
|
for (int i = 0; i < reader->iMax; i++) //根据读者可以借阅的数量作为循环终止条件
|
|
|
|
|
{
|
|
|
|
|
if (reader->aiBookId[i] != 0) //数组里不为0,证明有一条记录,因为:数组初始化为0,并且书的编号不可能为0
|
|
|
|
|
{
|
|
|
|
|
printf("%d\n", reader->aiBookId[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
printf("按任意键返回\n");
|
|
|
|
|
getchar();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
reader = reader->next;
|
|
|
|
|
}
|
|
|
|
|
printf("没有该读者!\n");
|
|
|
|
|
printf("按任意键返回\n");
|
|
|
|
|
getchar();
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
//查询读者信息
|
|
|
|
|
void foundReaderInfo(Reader* reader1)
|
|
|
|
|
{
|
|
|
|
|
Reader* reader = reader1;
|
|
|
|
|
printf("输入读者的id:");
|
|
|
|
|
int id;
|
|
|
|
|
scanf("%d", &id);
|
|
|
|
|
getchar();
|
|
|
|
|
while (reader)
|
|
|
|
|
{
|
|
|
|
|
if (id == reader->iNum)
|
|
|
|
|
{
|
|
|
|
|
printf("读者id:%d\n", reader->iNum);
|
|
|
|
|
printf("读者姓名:%s\n", reader->acName);
|
|
|
|
|
printf("读者性别:%s\n", reader->acSex);
|
|
|
|
|
printf("读者职位:%s\n", reader->position);
|
|
|
|
|
printf("读者已借阅书的数量:%d\n", reader->iAmount);
|
|
|
|
|
printf("按任意键返回\n");
|
|
|
|
|
getchar();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
reader = reader->next;
|
|
|
|
|
}
|
|
|
|
|
printf("没有找到该读者\n");
|
|
|
|
|
printf("按任意键返回\n");
|
|
|
|
|
getchar();
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
//读者借书
|
|
|
|
|
Reader* LendBook(Reader* reader1, Book* book1)
|
|
|
|
|
{
|
|
|
|
|