📄 sur_stu_func.c
字号:
/* file_name: sur_stu_func.c
* author: wangtiezhen miuliang @ Xidian University
* description:
*/
flag_type sur_stu_temp(void)
{
printf("hello, world.\n");
return session_ok;
}
flag_type stu_self_information(void)
{
struct stu* p = find_stu_num(stubt, user.id);
int n = bb_stu_borrow_num(bbbt, user.id);
printf("您好%s,您的借书号为%d,您总计借书%d本\n", p->name,p->num, n);
return session_ok;
}
int print_book_for_stu(struct book* p)
{
if(p == NULL){
printf("The book hasn't find.\n");
return -1;
}
printf("书号:%d,书名:%s,作者:%s,价格:%d\n",p->bnum, p->bname, p->bwriter, p->bprice);
}
flag_type stu_find_books()
{
printf("请选择搜索方式:\n"
"1.书号\n"
"2.书名\n"
"3.作者\n");
int i, n;
char c[20];
struct book* p = NULL;
if(scanf("%d", &i) != 1){
return -1;
}
switch(i){
case 1:
printf("请输入书号:");
scanf("%d", &n);
p = find_book_num(bookbt, n);
print_book_for_stu(p);
break;
case 2:
printf("请输入书名:");
scanf("%s", c);
p = find_book_name(bookbt, c);
print_book_for_stu(p);
break;
case 3:
printf("请输入作者:");
scanf("%s", c);
p = find_book_writer(bookbt, c);
print_book_for_stu(p);
break;
}
return session_ok;
}
flag_type stu_borrowed_books(void)
{
if( bb_borrowed(bbbt, user.id) == 0){
printf("you didn't borrowed any books.\n");
}
return session_ok;
}
int bb_borrowed(bbpointer root, int snum)
{
int n = 0;
// putchar('j');
if(root == NULL)
{
return 0;
}
n += bb_borrowed (root->lchild, snum );
if(root -> snum == snum){
n++;
struct book* p = find_book_num(bookbt, root->bnum);
print_book_for_stu(p);
}
n += bb_borrowed (root->rchild, snum );
return n;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -