c语言图书管理系统实践报告

}

}

input = getchar(); while(q != NULL) { }

printf(\

q->bi.book_load_time = 1; q = q->next;

3.辅助函数

在show_book中增加了部分显示图书的借阅状态,即被谁借了,借阅次数。

if(info->borrow_size == 'N'){

六.模块化设计user.c 1.预处理增加声明两个语句:

extern book* first_book; char borrow_user[20];

2.主要处理函数

(1)在删除用户函数中,即void delete_user,增加了一个条件,即当要删除的用户中有借书记录时,不得删除。并作出提示。

void delete_user(user* p)

} else{ }

printf(\被借总次数:%d\\n\//if(strcmp(info->borrow_user,\printf(\

if(strcmp(borrow_user,info->borrow_user) != 0)

printf(\借阅状态:已被借出\\n\printf(\借阅状态:你借了该图书\\n\printf(\借阅者:%s\\n\if(strcmp(borrow_user,info->borrow_user) == 0) if(strcmp(borrow_user,\printf(\借阅状态:未被借出\\n\//printf(\

{ }

(2)新增一个,能查看所有用户的函数,即void view_users,代码如下:

void view_users() {

char try_again = 'Y';

/*printf(\getchar(); getchar();*/ //p = p->next;

while (try_again == 'Y' || try_again == 'y') char input_char = 'N'; book *q = first_book; user* previous = NULL; int count = 0;

printf(\确定要删除用户 [%s] 吗?(y or n):\getchar();

input_char = getchar(); while(q != NULL) { }

if(count == 0) { } else { }

printf(\该用户有借书记录,不得删除!!!\if (input_char == 'Y' || input_char == 'y') { }

previous = get_previous_user(p); previous->next = p->next; free(p); p = NULL;

if(strcmp(q->bi.borrow_user,p->ui.username) == 0) { }

q = q->next;

count++;

}

{ }

user* p = first_user; p = p->next;

printf(\

printf(\ 账号 | 密码 |\\n\printf(\while(p != NULL) { }

printf(\需要再次查询用户信息么? 要 y 不要 n:\getchar();

try_again = getchar();

printf(\

printf(\ %-10s| %-10s|\\n\printf(\p = p->next;

(3)普通用户借书功能函数,即void borrow,代码如下:

void borrow(book* p) { }

(4)普通用户还书功能函数,代码如下: void _return(book* p) {

char sure = 'N';

if(strcmp(borrow_user,p->bi.borrow_user) == 0) {

printf(\确定要还书吗?(y or n)\getchar(); sure = getchar();

if(sure == 'y' || sure == 'Y') char sure = 'N';

printf(\确定要借阅吗?(y or n)\getchar(); sure = getchar();

if(sure == 'y' || sure == 'Y') { }

p->bi.borrow_size = 'Y'; p->bi.borrow_time++;

strcpy(p->bi.borrow_user,borrow_user);

}

}

{ }

p->bi.borrow_size = 'N';

strcpy(p->bi.borrow_user,\

(5)查看读者本人已借书籍,代码如下: void show_books_record() { }

3.2函数的规划和设计(即根据分析需要设计哪些函数及其之间的调用关系) 主菜单上对应的选项分别对应着各个函数,写成一个函数把菜单上的各个

函数包括起来。这样的函数有:

void (* admin_func[]),调用着add_book; view_book;

book* p = NULL; char input = 'Y';

while (input == 'y' || input == 'Y') { }

p = first_book;

printf(\

printf(\ 书名 | 作者 |\\n\printf(\while (p != NULL) { }

printf(\再次查阅已借书籍吗?(y or n):\getchar(); input = getchar();

if(strcmp(p->bi.borrow_user,borrow_user) == 0) { }

p = p->next;

printf(\printf(\

联系客服:779662525#qq.com(#替换为@) 苏ICP备20003344号-4