这里运用到一些文件,会在底层附上相应文件及其位置。

#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<windows.h>
#include<conio.h>
#include<time.h>
void start_show();                          //显示主面板
void main_menu(int);                        //显示主菜单
int login_system();                         //登陆系统
void registe_system();                      //注册系统
void exit_system();                         //退出系统
void jiami_input(char*);            //加密输入
void jiami_input_double(char*);     //加密输入重复
void reader_management();                                   //读者管理
void reader_information_input();                            //读者信息输入
void redear_information_modification();                     //读者信息修改
void redear_information_deletion();                         //读者信息删除
void redear_information_found();                            //读者信息查询
void redear_information_display();                          //读者信息显示
void book_management();                             //图书管理
void book_information_input();                      //图书信息输入
void book_information_modification();               //图书信息修改
void book_information_found(int);                   //图书信息查询
void book_number_found();           //按书号查询
void book_title_found();            //按书名查询
void book_author_found();           //按作者查询
void book_press_found();            //按出版社查询
void book_statistic();              //汇总统计
void user_management();                         //用户管理
void user_information_input();                  //用户信息输入
void user_information_modification();           //用户信息修改
void user_information_deletion();               //用户信息删除
void user_information_display();                //用户信息显示
void user_password_modification();              //用户密码修改
void book_liutong();                    //图书流通管理
void book_borrow();                     //借书处理
void book_return();                     //还书处理
void book_borrow_found();               //借阅查询
int write_user_data(struct User*, const char*);             //用户写入
int write_reader_data(struct Reader*, const char*);         //读者写入
int write_book_data(struct Book*, const char*);             //图书写入
int write_br_data(struct Jilu*, const char*);               //借还书写入
void free_user_data(struct User*);                  //释放用户链表内存
void free_reader_data(struct Reader*);              //释放读者链表内存
void free_book_data(struct Book*);                  //释放图书链表内存
void free_br_data(struct Jilu*);                    //释放借还书链表内存
void free_key_data(struct Key* head);               //释放检索表链表内存
struct User* temp_lian_user(struct User*);              //临时用户链表
struct Reader* temp_lian_reader(struct Reader*);        //临时读者链表
struct Book* temp_lian_book(struct Book*);              //临时图书链表
struct Jilu* temp_lian_br(struct Jilu*);                //临时借还书记录链表
struct Key* temp_lian_key(struct Key*, const char*);
struct Data current_system_time();                  //提取系统当前时间
void paixu_show(int);                                   //排序
const char* user_data = "D://booksystem//User.txt";              //用户文件
const char* reader_data = "D://booksystem//Reader.txt";          //读者文件
const char* book_data = "D://booksystem//Book.txt";              //图书文件
const char* br_data = "D://booksystem//Br.txt";                  //借还书记录文件
const char* name_data = "D://booksystem//book_name.txt";         //书名文件
const char* author_data = "D://booksystem//book_aut.txt";        //作者文件
const char* press_data = "D://booksystem//book_pre.txt";         //出版社文件
const int can_borrow_num = 10;                                         //初始可借数
const int been_borrow_num = 0;                                         //初始已借数
struct User
{char id[100];char password[100];char type[100];struct User* next;
};
struct Reader
{int id;char name[100];char company[100];char tele[100];int can_borrow;int been_borrow;struct Reader* next;
};
struct Book
{int num;char id[100];char name[100];char author[100];char press[100];int have;int borrow;int p1;int p2;int p3;struct Book* next;
};
struct Data
{int year;int month;int day;
};
struct Jilu
{char reader_name[100];char book_id[100];struct Data borrow_data;struct Data return_data;struct Jilu* next;
};
struct Key
{char keyword[100];int head;int lengh;struct Key* next;
};
int main()
{start_show();return 0;
}
void start_show(void)
{system("cls");int n, flag = 1;do {printf("******WELCOME!******\n");printf("1.登录\n");printf("2.注册\n");printf("0.退出\n");printf("请输入相关数字:");scanf("%d", &n);switch (n){case 1: main_menu(login_system());break;case 2:registe_system();break;case 0:exit_system();break;default:flag = 0;}if (flag == 0){printf("输入有误,请重新输入!\n");system("pause");}} while (flag != 1);
}
int login_system()
{struct User u1, u2;int u = 0, flag = -1,count = 0;system("cls");printf("***登录***\n");printf("请输入用户名:");scanf("%s", u1.id);printf("请输入密码:");jiami_input(u1.password);FILE* p;do{p = fopen(user_data, "r");if (p != NULL){while (fscanf(p, "%s%s%s", u2.id, u2.password, u2.type) != EOF){if (strcmp(u1.id, u2.id) == 0 && strcmp(u1.password, u2.password) != 0){flag = 1;count++;break;}else if (strcmp(u1.id, u2.id) != 0 && strcmp(u1.password, u2.password) == 0){flag = 2;break;}else if (strcmp(u1.id, u2.id) == 0 && strcmp(u1.password, u2.password) == 0){flag = 0;break;}}fclose(p);switch (flag){case 1:{if(count < 3){printf("登陆失败!\n");printf("您输入的密码有误!\n");printf("请重新输入密码!\n");jiami_input(u1.password);break;}else{printf("密码输入次数过多!\n");exit_system();}}case 2:case -1:{printf("登陆失败!\n");printf("您输入的用户名或密码错误!\n");printf("请重新输入!\n");printf("请输入用户名:");scanf("%s", u1.id);printf("请输入密码:");jiami_input(u1.password);break;}}}else{printf("\n");printf("文件未找到!\n");exit_system();}} while (flag != 0);if (strcmp(u2.type, "admin") == 0)u = 1;else if (strcmp(u2.type, "lib") == 0)u = 2;else if (strcmp(u2.type, "reader") == 0)u = 3;return u;
}
void registe_system()
{struct Reader r1;struct User us1, us2;system("cls");printf("\t\t****欢迎来到注册系统!****\n");printf("请输入你的用户名:");scanf("%s", us1.id);printf("请输入你的密码:");jiami_input_double(us1.password);printf("\n");printf("请输入你的姓名:");scanf("%s", r1.name);printf("请输入你的公司:");scanf("%s", r1.company);printf("请输入你的联系方式:");scanf("%s", r1.tele);int flag;do{flag = 0;FILE* fp = fopen(user_data, "r");while (fscanf(fp, "%s %s %s", us2.id, us2.password, us2.type) != EOF){if (strcmp(us1.id, us2.id) == 0){flag = 1;printf("该用户名已被注册,请重新输入!\n");printf("请输入用户名:");scanf("%s", us1.id);break;}}fclose(fp);} while (flag != 0);FILE* fpr = fopen(reader_data, "a");FILE* fpu = fopen(user_data, "a");if (fpr == NULL || fpu == NULL){printf("文件打开失败!\n");exit_system();}else{fprintf(fpr, "%d %s %s %s %d %d\n", r1.id, r1.name, r1.company, r1.tele, can_borrow_num, been_borrow_num);fprintf(fpu, "%s %s %s\n", us1.id, us1.password, "reader");fclose(fpr);fclose(fpu);}int flag1;do{system("cls");printf("注册成功!\n");printf("1.返回主界面\n");printf("0.退出\n");printf("请输入对应编号\n");int n;scanf("%d", &n);flag1 = 0;switch (n){case 1: start_show();break;case 0: exit_system();break;default: flag1 = 1;}if (flag1 == 1){printf("输入有误,请重新输入!\n");system("pause");}} while (flag1 != 0);
}
void main_menu(int u)
{if (u == 1){int flag;do{system("cls");printf("\t\t***欢迎系统管理员登录***\n");printf("1.用户管理\n");printf("2.返回登录页面\n");printf("0.退出\n");printf("请输入对应编号!\n");int n1;flag = 0;scanf("%d", &n1);switch (n1){case 1: user_management();break;case 2: start_show();break;case 0: exit_system();break;default: flag = 1;}if (flag == 1){printf("输入错误,请重新输入\n");system("pause");}} while (flag != 0);}else if (u == 2){int flag;do{system("cls");printf("\t\t****欢迎图书管理员登录****\n");printf("1.读者管理\n");printf("2.图书管理\n");printf("3.图书流通管理\n");printf("4.返回登录页面\n");printf("0.退出\n");printf("请输入对应编号!\n");int n1;scanf("%d", &n1);flag = 0;switch (n1){case 1: reader_management();break;case 2: book_management();break;case 3: book_liutong();break;case 4: start_show();break;case 0: exit_system();break;default: flag = 1;}if (flag == 1){printf("输入错误,请重新输入\n");system("pause");}} while (flag != 0);}else if (u == 3){int flag;do{system("cls");printf("\t\t****欢迎读者登录****\n");printf("1.密码修改\n");printf("2.图书查询\n");printf("3.借阅查询\n");printf("4.返回登录页面\n");printf("0.退出\n");printf("请输入对应编号!\n");int n1;scanf("%d", &n1);flag = 0;switch (n1){case 1:{user_password_modification();system("pause");int flag1;do{system("cls");printf("1.返回上一级\n");printf("0.退出\n");printf("请输入对应编号:");int n;flag1 = 0;scanf("%d", &n);switch (n){case 1:    main_menu(3);break;case 0: exit_system();break;default: flag1 = 1;}if (flag1 == 1){printf("输入有误,请重新输入:");system("pause");}} while (flag1 != 0);break;}case 2: book_information_found(1);break;case 3: book_borrow_found();break;case 4: start_show();break;case 0: exit_system();break;default: flag = 1;}if (flag == 1){printf("输入错误,请重新输入\n");system("pause");}} while (flag != 0);}
}
void exit_system()
{printf("感谢使用!\n");exit(0);
}
void jiami_input(char* str)
{char password[100];int i = 0;while ((password[i] = _getch()) != '\r'){printf("*");i++;}password[i] = '\0';strcpy(str, password);
}
void jiami_input_double(char* str)
{char password[100];char password_a[100];int flag;do{int i = 0;flag = 0;while ((password[i] = _getch()) != '\r'){printf("*");i++;}password[i] = '\0';printf("\n");printf("请再次输入密码:");i = 0;while ((password_a[i] = _getch()) != '\r'){printf("*");i++;}password_a[i] = '\0';if (strcmp(password, password_a) != 0){flag = 1;printf("两次输入的密码不一致,请重新输入!\n");}} while (flag != 0);strcpy(str, password);
}
void user_management()
{int flag;do{system("cls");printf("用户管理\n");printf("1.用户信息输入\n");printf("2.用户信息修改\n");printf("3.用户信息删除\n");printf("4.用户信息显示\n");printf("5.用户密码修改\n");printf("6.返回主菜单\n");printf("0.退出\n");int n;scanf("%d", &n);flag = 0;switch (n){case 1: user_information_input();break;case 2: user_information_modification();break;case 3: user_information_deletion();break;case 4: user_information_display();break;case 5: user_password_modification();break;case 6: main_menu(1);break;case 0: exit_system();break;default: flag = 1;}if (flag == 1){printf("输入有误,请重新输入!\n");system("pause");}} while (flag != 0);
}
void reader_management()
{int flag;do{system("cls");printf("读者管理\n");printf("1.读者信息输入\n");printf("2.读者信息修改\n");printf("3.读者信息删除\n");printf("4.读者信息查询\n");printf("5.读者信息显示\n");printf("6.返回主菜单\n");printf("0.退出\n");int n;scanf("%d", &n);flag = 0;switch (n){case 1: reader_information_input();break;case 2: redear_information_modification();break;case 3: redear_information_deletion();break;case 4: redear_information_found();break;case 5: redear_information_display();break;case 6: main_menu(2);break;case 0: exit_system();break;default: flag = 1;}if (flag == 1){printf("输入有误,请重新输入!\n");system("pause");}} while (flag != 0);
}
void book_management()
{int flag1;do{printf("1.图书信息输入\n");printf("2.图书信息修改\n");printf("3.图书信息查询\n");printf("4.汇总统计\n");printf("5.返回上一级\n");printf("0.退出\n");printf("请输入对应编号:");int n;scanf("%d", &n);flag1 = 0;switch (n){case 1: book_information_input();break;case 2: book_information_modification();break;case 3: book_information_found(2);break;case 4:book_statistic();system("pasue");int flag2;do{system("cls");printf("1.返回上一级\n");printf("0.退出\n");printf("请输入对应编号:");int n1;scanf("%d", &n1);flag2 = 0;switch (n1){case 1: book_management();break;case 0: exit_system();break;default: flag2 = 1;}if (flag2 == 1){printf("输入有误,请重新输入:");system("pause");}} while (flag2 != 0);case 5: main_menu(2);break;case 0: exit_system();break;default: flag1 = 1;}if (flag1 == 1){printf("输入有误,请重新输入:");system("pause");}} while (flag1 != 0);
}
void book_liutong()
{int flag1;do{system("cls");printf("1.借书处理\n");printf("2.还书处理\n");printf("3.返回上一级\n");printf("0.退出\n");printf("请输入对用编号:");int n1;scanf("%d", &n1);flag1 = 0;switch (n1){case 1: book_borrow();break;case 2: book_return();break;case 3: main_menu(2);break;case 0: exit_system();break;default: flag1 = 1;}if (flag1 == 1){printf("输入有误,请重新输入:");system("pause");}} while (flag1 != 0);
}
void book_information_found(int n)
{int flag1;do{system("cls");printf("1.按书号查询\n");printf("2.按书名查询\n");printf("3.按作者查询\n");printf("4.按出版社查询\n");printf("5.返回上一级\n");printf("0.退出\n");printf("请输入对应编号:");int n1;scanf("%d", &n1);flag1 = 0;switch (n1){case 1: book_number_found();break;case 2: book_title_found();break;case 3: book_author_found();break;case 4:  book_press_found();break;case 5:{if (n == 1)main_menu(3);elsebook_management();break;}case 0: exit_system();break;default: flag1 = 1;}if (flag1 == 1){printf("输入有误,请重新输入:");system("pause");}} while (flag1 != 0);
}
void book_information_input()
{struct Book temp_xin;printf("请输入书号:");scanf("%s", temp_xin.id);printf("请输入书名:");scanf("%s", temp_xin.name);printf("请输入书作者:");scanf("%s", temp_xin.author);printf("请输入书出版社:");scanf("%s", temp_xin.press);printf("请输入书库存:");scanf("%d", &temp_xin.have);temp_xin.borrow = 0;printf("请输入相关检索信息:");scanf("%d %d %d", &temp_xin.p1, &temp_xin.p2, &temp_xin.p3);struct Book* head = NULL;FILE* fp = fopen(book_data, "r");if (fp == NULL){printf("文件打开失败!\n");exit_system();}else{struct Book temp;struct Book* current = NULL, * prev = NULL;int i = 0;while (fscanf(fp, "%d %s %s %s %s %d %d %d %d %d", &temp.num, temp.id, temp.name, temp.author, temp.press, &temp.have, &temp.borrow, &temp.p1, &temp.p2, &temp.p3) != EOF){i++;current = (struct Book*)malloc(sizeof(struct Book));current->num = temp.num;strcpy(current->id, temp.id);strcpy(current->name, temp.name);strcpy(current->author, temp.author);strcpy(current->press, temp.press);current->have = temp.have;current->borrow = temp.borrow;current->p1 = temp.p1;current->p2 = temp.p2;current->p3 = temp.p3;current->next = NULL;if (head == NULL)head = current;elseprev->next = current;prev = current;}current = (struct Book*)malloc(sizeof(struct Book));current->num = i;strcpy(current->id, temp_xin.id);strcpy(current->name, temp_xin.name);strcpy(current->author, temp_xin.author);strcpy(current->press, temp_xin.press);current->have = temp_xin.have;current->borrow = temp_xin.borrow;current->p1 = temp_xin.p1;current->p2 = temp_xin.p2;current->p3 = temp_xin.p3;current->next = NULL;prev->next = current;}fclose(fp);int flag;flag = write_book_data(head, book_data);if (flag == 0)printf("写入失败!\n");elseprintf("写入成功!\n");system("pause");int flag1;do{system("cls");printf("1.返回上一级\n");printf("0.退出\n");printf("请输入对应编号:");int n1;scanf("%d", &n1);flag1 = 0;switch (n1){case 1: book_management();break;case 0: exit_system();break;default: flag1 = 1;}if (flag1 == 1){printf("输入有误,请重新输入:");system("pause");}} while (flag1 != 0);
}
void book_information_modification()
{struct Book temp;struct Book* head = NULL, * p, * L;int flag1 = 1;L = p = temp_lian_book(head);printf("请输入书本号:");scanf("%s", temp.id);while (p){if (strcmp(temp.id, p->id) == 0){flag1 = 0;printf("请输入书本库存:");scanf("%d", &p->have);}p = p->next;}if (flag1)printf("未找到该书\n");else{if (write_book_data(L, book_data) == 0)printf("写入失败\n");elseprintf("写入成功\n");}system("pause");int flag2;do{system("cls");printf("1.返回上一级\n");printf("0.退出\n");printf("请输入对应编号:");int n1;flag2 = 0;scanf("%d", &n1);switch (n1){case 1: book_management();break;case 0: exit_system();break;default: flag2 = 1;}if (flag2 == 1){printf("输入有误,请重新输入:");system("pause");}} while (flag2 != 0);
}
void book_borrow_found()
{char temp_id[100];struct Reader* head = NULL, * p, * L;int flag1 = 1;p = L = temp_lian_reader(head);printf("请输入你的用户名:");scanf("%s", temp_id);while (p){if (strcmp(temp_id, p->name) == 0){flag1 = 0;printf("可借数量为:");printf("%d\n", p->can_borrow);printf("已借数量为:");printf("%d\n", p->been_borrow);}p = p->next;}if (flag1){printf("用户名未找到!\n");system("pause");}int flag2;do{system("cls");printf("1.返回上一级\n");printf("0.退出\n");printf("请输入对应编号:");int n1;flag2 = 0;scanf("%d", &n1);switch (n1){case 1: main_menu(3);break;case 0: exit_system();break;default: flag2 = 1;}if (flag2 == 1){printf("输入有误,请重新输入:");system("pause");}} while (flag2 != 0);
}
void book_statistic()
{system("cls");struct Book* head = NULL, * p, * kill;p = kill = temp_lian_book(head);while (p){printf("%s %s %s %s %d\n", p->id, p->name, p->author, p->press, p->have - p->borrow);p = p->next;}free_book_data(kill);system("pause");
}
void user_information_input()
{system("cls");struct User* head = NULL;struct User temp_xin;FILE* fp = fopen(user_data, "r");if (fp == NULL){printf("文件打开失败!\n");system("pause");exit_system();}else{printf("请输入新用户名:");scanf("%s", temp_xin.id);printf("请输入新用户密码:");jiami_input(temp_xin.password);printf("\n");printf("请输入新用户类型:");scanf("%s", temp_xin.type);struct User temp;struct User* current = NULL, * prev = NULL; \while (fscanf(fp, "%s %s %s", temp.id, temp.password, temp.type) != EOF){current = (struct User*)malloc(sizeof(struct User));strcpy(current->id, temp.id);strcpy(current->password, temp.password);strcpy(current->type, temp.type);current->next = NULL;if (head == NULL)head = current;elseprev->next = current;prev = current;}current = (struct User*)malloc(sizeof(struct User));strcpy(current->id, temp_xin.id);strcpy(current->password, temp_xin.password);strcpy(current->type, temp_xin.type);current->next = NULL;if (head == NULL)head = current;elseprev->next = current;}if (write_user_data(head, user_data) == 0)printf("写入失败!\n");elseprintf("写入成功!\n");system("pause");int flag;do{system("cls");printf("1.返回上一级\n");printf("0.退出\n");printf("请输入对应编号!\n");int n;scanf("%d", &n);flag = 0;switch (n){case 1: user_management();break;case 0:   exit_system();break;default: flag = 1;}if (flag == 1){printf("输入有误,请重新输入!\n");system("pause");}} while (flag != 0);
}
void user_information_modification()
{int flag;int flag1 = 0;do{system("cls");printf("1.用户类型\n");printf("2.重置密码\n");printf("0.返回上一级\n");printf("请输入对应编号:");int n;scanf("%d", &n);flag = 0;switch (n){case 1: flag1 = 1;break;case 2: flag1 = 2;break;case 0: user_management();break;default: flag = 1;}if (flag == 1){printf("输入有误,请重新输入!\n");system("pause");}} while (flag != 0);if (flag1 == 1){system("cls");char temp_id[100];struct User* head = NULL, * p, * L;int flag2 = 1;p = L = temp_lian_user(head);printf("请输入要修改信息用户名:");scanf("%s", temp_id);while (p){if (strcmp(temp_id, p->id) == 0){flag2 = 0;printf("请输入用户新类型:");scanf("%s", p->type);}p = p->next;}if (flag2)printf("未找到该用户!\n");else{if (write_user_data(L, user_data) == 0)printf("写入失败!\n");elseprintf("写入成功!\n");}system("pause");int flag3;do{system("cls");printf("1.返回上一级\n");printf("0.退出\n");int n1;scanf("%d", &n1);flag3 = 0;switch (n1){case 1: user_information_modification();break;case 0: exit_system();break;default:flag3 = 1;}if (flag3 == 1){printf("输入有误,请重新输入!\n");system("pause");}} while (flag3 != 0);}else if (flag1 == 2){system("cls");char temp_id[100];struct User* head = NULL, * p, * L;int flag2 = 1;p = L = temp_lian_user(head);printf("请输入要修改信息用户名:");scanf("%s", temp_id);while (p){if (strcmp(temp_id, p->id) == 0){flag2 = 0;strcpy(p->password, "123123");}p = p->next;}if (flag2)printf("未找到该用户!\n");else{if (write_user_data(L, user_data) == 0)printf("重置失败!\n");elseprintf("重置成功!\n密码为:123123\n");}system("pause");int flag3;do{system("cls");printf("1.返回上一级\n");printf("0.退出\n");int n1;scanf("%d", &n1);flag3 = 0;switch (n1){case 1: user_information_modification();break;case 0: exit_system();break;default:flag3 = 1;}if (flag3 == 1){printf("输入有误,请重新输入!\n");system("pause");}} while (flag3 != 0);}
}
void user_information_deletion()
{system("cls");char temp_id[100];struct User* up, * utail, * uhead = NULL, * ukill;int flag1 = 1;up = utail = uhead = temp_lian_user(uhead);printf("请输入需要删除的用户名:");scanf("%s", temp_id);while (up){if (strcmp(up->id, temp_id) == 0){flag1 = 0;if (up == uhead)uhead = uhead->next;elseutail->next = up->next;ukill = up;up = up->next;free(ukill);}else{utail = up;up = up->next;}}struct Reader* rp, * rtail, * rhead = NULL, * rkill;int flag2 = 1;rp = rtail = rhead = temp_lian_reader(rhead);while (rp){if (strcmp(rp->name, temp_id) == 0){flag2 = 0;if (rp == rhead)rhead = rhead->next;elsertail->next = rp->next;rkill = rp;rp = rp->next;free(rkill);}else{rtail = rp;rp = rp->next;}}if (flag1 || flag2)printf("未找到该用户!\n");else{int s_flag1 = 1, s_flag2 = 1;s_flag1 = write_user_data(uhead, user_data);s_flag2 = write_reader_data(rhead, reader_data);if (s_flag1 == 0 && s_flag2 == 0)printf("删除失败!\n");elseprintf("删除成功!\n");}system("pause");int flag3;do{system("cls");printf("1.返回上一级\n");printf("0.退出\n");printf("请输入对应编号\n");int n;scanf("%d", &n);flag3 = 0;switch (n){case 1: user_management();break;case 2: exit_system();break;default: flag3 = 1;}if (flag3 == 1){printf("输入有误,请重新输入!\n");system("pause");}} while (flag3 != 0);
}
void user_information_display()
{paixu_show(1);system("pause");int flag;do{system("cls");printf("1.返回上一级\n");printf("0.退出\n");printf("请输入对应编号\n");int n;scanf("%d", &n);flag = 0;switch (n){case 1: user_management();break;case 2: exit_system();break;default: flag = 1;}if (flag == 1){printf("输入有误,请重新输入!\n");system("pause");}} while (flag != 0);
}
void user_password_modification()
{system("cls");char temp_id[100];char temp_password[100];char old_password[100];struct User* head = NULL, * p, * L;int flag1 = 1;L = p = temp_lian_user(head);printf("请输入用户名:");scanf("%s", temp_id);while (p){if (strcmp(temp_id, p->id) == 0){flag1 = 0;int flag2 = 1;do{printf("请输入原密码:");jiami_input(old_password);if (strcmp(old_password, p->password) == 0){flag2 = 0;printf("\n");printf("请输入新密码:");jiami_input(temp_password);strcpy(p->password, temp_password);}else{printf("原密码错误,请重新输入!\n");system("pause");}} while (flag2 != 0);break;}p = p->next;}if (flag1 == 1)printf("未找到用户!\n");else{int flag3 = 1;flag3 = write_user_data(L, user_data);if (flag3 == 0)printf("修改失败!\n");elseprintf("修改成功!\n");}
}
void reader_information_input()
{int flag1 = 1, flag2 = 1;struct User* head = NULL;struct User temp_xin;FILE* fp = fopen(user_data, "r");if (fp == NULL){printf("文件打开失败!\n");system("pause");exit_system();}else{printf("请输入新用户名:");scanf("%s", temp_xin.id);printf("请输入新用户密码:");jiami_input(temp_xin.password);strcpy(temp_xin.type, "reader");struct User temp;struct User* current = NULL, * prev = NULL;while (fscanf(fp, "%s %s %s", temp.id, temp.password, temp.type) != EOF){current = (struct User*)malloc(sizeof(struct User));strcpy(current->id, temp.id);strcpy(current->password, temp.password);strcpy(current->type, temp.type);current->next = NULL;if (head == NULL)head = current;elseprev->next = current;prev = current;}current = (struct User*)malloc(sizeof(struct User));strcpy(current->id, temp_xin.id);strcpy(current->password, temp_xin.password);strcpy(current->type, temp_xin.type);current->next = NULL;if (head == NULL)head = current;elseprev->next = current;}struct Reader* rhead = NULL, * rrp = NULL;struct Reader rtemp_xin;FILE* rfp = fopen(reader_data, "r");if (rfp == NULL){printf("文件打开失败!\n");system("pause");exit_system();}else{struct Reader* rcurrent = NULL, * rprev = NULL;while (fscanf(rfp, "%d %s %s %s %d %d", &rtemp_xin.id, rtemp_xin.name, rtemp_xin.company, rtemp_xin.tele, &rtemp_xin.can_borrow, &rtemp_xin.been_borrow) != EOF){rcurrent = (struct Reader*)malloc(sizeof(struct Reader));rcurrent->id = rtemp_xin.id;strcpy(rcurrent->name, rtemp_xin.name);strcpy(rcurrent->company, rtemp_xin.company);strcpy(rcurrent->tele, rtemp_xin.tele);rcurrent->can_borrow = rtemp_xin.can_borrow;rcurrent->been_borrow = rtemp_xin.been_borrow;rcurrent->next = NULL;if (rhead == NULL)rhead = rcurrent;elserprev->next = rcurrent;rprev = rcurrent;}printf("请输入读者工作单位:");scanf("%s", rtemp_xin.company);printf("请输入读者联系方式:");scanf("%s", rtemp_xin.tele);rcurrent = (struct Reader*)malloc(sizeof(struct Reader));rcurrent->id = rtemp_xin.id + 1;strcpy(rcurrent->name, temp_xin.id);strcpy(rcurrent->company, rtemp_xin.company);strcpy(rcurrent->tele, rtemp_xin.tele);rcurrent->can_borrow = can_borrow_num;rcurrent->been_borrow = been_borrow_num;rcurrent->next = NULL;if (rhead == NULL)rhead = rcurrent;elserprev->next = rcurrent;}rrp = rhead;while (rrp){printf("id=%d\n", rrp->id);rrp = rrp->next;}flag1 = write_user_data(head, user_data);flag2 = write_reader_data(rhead, reader_data);if (flag1 == 0 || flag2 == 0)printf("写入失败!\n");elseprintf("写入成功!\n");system("pause");int flag3;do{system("cls");printf("1.返回上一级\n");printf("0.退出\n");printf("请输入对应编号\n");int n;scanf("%d", &n);flag3 = 0;switch (n){case 1: reader_management();break;case 0: exit_system();break;default: flag3 = 1;}if (flag3 == 1){printf("输入有误,请重新输入!\n");system("pause");}} while (flag3 != 0);
}
void redear_information_modification()
{struct Reader temp_xin;char temp_id[100];struct Reader* head = NULL, * rp, * L;int flag1 = 1;rp = L = temp_lian_reader(head);printf("请输入要修改信息用户名:");scanf("%s", temp_id);while (rp){if (strcmp(temp_id, rp->name) == 0){flag1 = 0;printf("请输入读者号:");scanf("%d", &temp_xin.id);printf("请输入读者新工作单位:");scanf("%s", temp_xin.company);strcpy(rp->company, temp_xin.company);printf("请输入读者新联系方式:");scanf("%s", temp_xin.tele);strcpy(rp->tele, temp_xin.tele);}rp = rp->next;}if (flag1)printf("未找到该用户!\n");else{if (write_reader_data(L, reader_data) == 0)printf("写入失败!\n");elseprintf("写入成功!\n");}system("pause");int flag3;do{system("cls");printf("1.返回上一级\n");printf("0.退出\n");int n1;scanf("%d", &n1);flag3 = 0;switch (n1){case 1: reader_management();break;case 0: exit_system();break;default:flag3 = 1;}if (flag3 == 1){printf("输入有误,请重新输入!\n");system("pause");}} while (flag3 != 0);
}
void redear_information_deletion()
{char temp_xin[100];struct User* head = NULL, * up, * uhead, * utail, * ukill;up = uhead = utail = temp_lian_user(head);int flag1 = 1;printf("qingshuru:");scanf("%s", temp_xin);while (up){if (strcmp(temp_xin, up->id) == 0){flag1 = 0;if (up == uhead)uhead = uhead->next;elseutail->next = up->next;ukill = up;up = up->next;free(ukill);}else{utail = up;up = up->next;}}struct Reader* rrhead = NULL, * rp, * rhead = NULL, * rtail, * rkill;rp = rhead = rtail = temp_lian_reader(rhead);int flag2 = 1;while (rp){if (strcmp(temp_xin, rp->name) == 0){flag2 = 0;if (rp == rhead)rhead = rhead->next;elsertail->next = rp->next;rkill = rp;rp = rp->next;free(rkill);}else{rtail = rp;rp = rp->next;}}if (flag1 || flag2)printf("weizhaodao\n");else{int flag3 = 1;int flag4 = 1;flag3 = write_user_data(uhead, user_data);flag4 = write_reader_data(rhead, reader_data);if (flag3 == 0)printf("shanchushibai!\n");elseprintf("shanchuchenggong!\n");}system("pause");int flag5;do{system("cls");printf("1.fanhui\n");printf("0.tuichu\n");printf("qingshuru:");int n;scanf("%d", &n);flag5 = 0;switch (n){case 1: reader_management();break;case 2: exit_system();break;default: flag5 = 1;}if (flag5 == 1){printf("wuruyouwu\n");system("pause");}} while (flag5 != 0);
}
void redear_information_found()
{char temp_xin[100];printf("请输入用户名:");scanf("%s", temp_xin);struct Reader* rhead = NULL, * rp, * rtail;rp = rtail = temp_lian_reader(rhead);int flag1 = 1;while (rp){if (strcmp(temp_xin, rp->name) == 0){flag1 = 0;printf("序号:%d\n", rp->id);printf("用户名:%s\n", rp->name);printf("公司:%s\n", rp->company);printf("联系方式:%s\n", rp->tele);printf("可借:%d\n", rp->can_borrow);printf("已借:%d\n", rp->been_borrow);system("pause");break;}else{rtail = rp;rp = rp->next;}}if (flag1){printf("未找到该用户!\n");system("pause");}int flag2;do{system("cls");printf("1.返回上一级\n");printf("0.退出\n");printf("请输入对应编号:");flag2 = 0;int n;scanf("%d", &n);switch (n){case 1: reader_management();break;case 0: exit_system();break;default: flag2 = 1;}if (flag2 == 1){printf("输入有误,请重新输入\n");system("pause");}} while (flag2 != 0);
}
void redear_information_display()
{paixu_show(2);system("pause");int flag1;do{system("cls");printf("1.返回上一级\n");printf("0.退出\n");printf("请输入对应编号:");int n;scanf("%d", &n);flag1 = 0;switch (n){case 1: reader_management();break;case 2: exit_system();break;default: flag1 = 1;}if (flag1 == 1){printf("输入有误,请重新输入!\n");system("pause");}} while (flag1 != 0);
}
int write_user_data(struct User* head, const char* wenjian)
{FILE* fp = fopen(wenjian, "w");struct User* kill = head;if (fp == NULL)return 0;while (head){fprintf(fp, "%s %s %s\n", head->id, head->password, head->type);head = head->next;}free_user_data(kill);fclose(fp);return 1;
}
int write_reader_data(struct Reader* head, const char* wenjian)
{FILE* fp = fopen(wenjian, "w");struct Reader* kill = head;if (fp == NULL)return 0;while (head){fprintf(fp, "%d %s %s %s %d %d\n", head->id, head->name, head->company, head->tele, head->can_borrow, head->been_borrow);head = head->next;}free_reader_data(kill);fclose(fp);return 1;
}
int write_book_data(struct Book* head, const char* wenjian)
{FILE* fp = fopen(wenjian, "w");struct Book* kill = head;if (fp == NULL)return 0;while (head){fprintf(fp, "%d %s %s %s %s %d %d %d %d %d\n", head->num, head->id, head->name, head->author, head->press, head->have, head->borrow, head->p1, head->p2, head->p3);head = head->next;}free_book_data(kill);fclose(fp);return 1;
}
void free_user_data(struct User* head)
{struct User* freehead;while (head != NULL){freehead = head;head = head->next;free(freehead);}
}
void free_reader_data(struct Reader* head)
{struct Reader* freehead;while (head != NULL){freehead = head;head = head->next;free(freehead);}
}
void free_book_data(struct Book* head)
{struct Book* freehead;while (head != NULL){freehead = head;head = head->next;free(freehead);}
}
struct Book* temp_lian_book(struct Book* head)
{FILE* fp = fopen(book_data, "r");if (NULL == fp){printf("系统出错,文件打开失败!\n");exit_system();}else{struct Book temp;struct Book* current = NULL, * prev = NULL;while (fscanf(fp, "%d %s %s %s %s %d %d %d %d %d", &temp.num, temp.id, temp.name, temp.author, temp.press, &temp.have, &temp.borrow, &temp.p1, &temp.p2, &temp.p3) != EOF){current = (struct Book*)malloc(sizeof(struct Book));current->num = temp.num;strcpy(current->id, temp.id);strcpy(current->name, temp.name);strcpy(current->author, temp.author);strcpy(current->press, temp.press);current->have = temp.have;current->borrow = temp.borrow;current->p1 = temp.p1;current->p2 = temp.p2;current->p3 = temp.p3;current->next = NULL;if (NULL == head)head = current;elseprev->next = current;prev = current;}}return head;
}
struct User* temp_lian_user(struct User* head)
{FILE* fp = fopen(user_data, "r");if (fp != NULL){struct User temp;struct User* current = NULL, * prev = NULL;while (fscanf(fp, "%s %s %s", temp.id, temp.password, temp.type) != EOF){current = (struct User*)malloc(sizeof(struct User));strcpy(current->id, temp.id);strcpy(current->password, temp.password);strcpy(current->type, temp.type);current->next = NULL;if (head == NULL)head = current;elseprev->next = current;prev = current;}}else{printf("系统出错\n");exit_system();}return head;
}
struct Reader* temp_lian_reader(struct Reader* head)
{FILE* fp = fopen(reader_data, "r");if (fp != NULL){struct Reader temp;struct Reader* current = NULL, * prev = NULL;while (fscanf(fp, "%d %s %s %s %d %d", &temp.id, temp.name, temp.company, temp.tele, &temp.can_borrow, &temp.been_borrow) != EOF){current = (struct Reader*)malloc(sizeof(struct Reader));current->id = temp.id;strcpy(current->name, temp.name);strcpy(current->company, temp.company);strcpy(current->tele, temp.tele);current->can_borrow = temp.can_borrow;current->been_borrow = temp.been_borrow;current->next = NULL;if (head == NULL)head = current;elseprev->next = current;prev = current;}}else{printf("系统出错\n");exit_system();}return head;
}
void paixu_show(int n)
{system("cls");if (n == 1){struct User* head = NULL, * p, * p1, * p2, * x, * t;p = temp_lian_user(head);p1 = p->next;p->next = NULL;while (p1 != NULL){x = p;p2 = p->next;while (p2 != NULL && strcmp(p2->id, p1->id) <= 0){x = p2;p2 = p2->next;}t = p1->next;p1->next = p2;x->next = p1;p1 = t;}p1 = p;struct User* kill = p1;while (p1 != NULL){printf("%s %s\n", p1->id, p1->type);p1 = p1->next;}free_user_data(kill);}if (2 == n){struct Reader* head = NULL, * p, * p1, * p2, * x, * t;p = temp_lian_reader(head);p1 = p->next;p->next = NULL;while (p1 != NULL){x = p;p2 = p->next;while (p2 != NULL && strcmp(p2->name, p1->name) <= 0){x = p2;p2 = p2->next;}t = p1->next;p1->next = p2;x->next = p1;p1 = t;}p1 = p;while (p1 != NULL){printf("%d %s %s %d %d\n", p1->id, p1->company, p1->tele, p1->can_borrow, p1->been_borrow);p1 = p1->next;}struct Reader* kill = p1;free_reader_data(kill);}
}
void book_borrow()
{char book_id[100];char reader_name[100];printf("请输入用户名:");scanf("%s", reader_name);printf("请输入书本号:");scanf("%s", book_id);struct Reader* head = NULL, * p;int flag1 = 1;p = temp_lian_reader(head);while (p){if (strcmp(reader_name, p->name) == 0){flag1 = 0;if (p->can_borrow > p->been_borrow){int flag2 = 0;struct Jilu* jhead = NULL, * jp = NULL, * jL = NULL;jL = jp = temp_lian_br(jhead);while (jp){if (strcmp(reader_name, jp->reader_name) == 0 && strcmp(book_id, jp->book_id) == 0 && jp->return_data.year == 0){flag2 = 1;break;}jp = jp->next;}if (flag2){printf("该用户已借此书,并未归还!\n");printf("借书日期:%d-%d-%d\n", jp->borrow_data.year, jp->borrow_data.month, jp->borrow_data.day);}else{struct Book* p, * head = NULL;int flag3 = 1;p = temp_lian_book(head);while (p){if (strcmp(book_id, p->id) == 0){flag3 = 0;if (p->have > p->borrow){struct Jilu* head = NULL, * p = NULL, * L = NULL;L = p = temp_lian_br(head);if (p != NULL)while (p->next)p = p->next;struct Jilu* current = NULL;struct Data nowtime = current_system_time();current = (struct Jilu*)malloc(sizeof(struct Jilu));strcpy(current->reader_name, reader_name);strcpy(current->book_id, book_id);current->borrow_data.year = nowtime.year;current->borrow_data.month = nowtime.month;current->borrow_data.day = nowtime.day;current->return_data.year = 0;current->return_data.month = 0;current->return_data.day = 0;current->next = NULL;if (L == NULL)L = current;elsep->next = current;int f;f = write_br_data(L, br_data);if (f == 0)printf("写入失败!\n");elseprintf("写入成功!\n");struct Book* bhead = NULL, * bp, * bL;bL = bp = temp_lian_book(bhead);while (bp){if (strcmp(book_id, bp->id) == 0)bp->borrow++;bp = bp->next;}if (write_book_data(bL, book_data) == 0)printf("写入失败!\n");elseprintf("写入成功!\n");struct Reader* rhead = NULL, * rp, * rL;rp = rL = temp_lian_reader(rhead);while (rp){if (strcmp(reader_name, rp->name) == 0)rp->been_borrow++;rp = rp->next;}if (write_reader_data(rL, reader_data) == 0)printf("写入失败!\n");elseprintf("写入成功!\n");}elseprintf("此书已全部借出!\n");}p = p->next;}if (flag3)printf("未找到此书!\n");}}elseprintf("已达最大可借数!\n");}p = p->next;}if (flag1)printf("未找到该用户!\n");system("pause");int flag4;do{system("cls");printf("1.返回上一级\n");printf("0.退出\n");printf("请输入对应编号:");int n;scanf("%d", &n);flag4 = 0;switch (n){case 1: book_liutong();break;case 2: exit_system();break;default: flag4 = 1;}if (flag4 == 1){printf("输入有误,请重新输入!\n");system("pause");}} while (flag4 != 0);
}
void book_return()
{char reader_name[100];char book_id[100];printf("请输入用户名:");scanf("%s", reader_name);printf("请输入书本号:");scanf("%s", book_id);struct Reader* head = NULL, * p;int flag1 = 1;p = temp_lian_reader(head);while (p){if (strcmp(reader_name, p->name) == 0){flag1 = 0;int flag2 = 1;struct Jilu* jhead = NULL, * jp = NULL, * jL = NULL;jp = jL = temp_lian_br(jhead);while (jp){if (strcmp(reader_name, jp->reader_name) == 0 && strcmp(book_id, jp->book_id) == 0 && jp->return_data.year == 0){flag2 = 0;break;}jp = jp->next;}if (flag2)printf("未找到此用户的记录!\n");else{struct Book* head = NULL, * p;p = temp_lian_book(head);int flag3 = 0;while (p){if (strcmp(book_id, p->id) == 0){flag3 = 1;struct Jilu* head = NULL, * p = NULL, * L = NULL;p = L = temp_lian_br(head);while (p){if (strcmp(book_id, p->book_id) == 0 && p->return_data.year == 0){struct Data nowtime = current_system_time();p->return_data.year = nowtime.year;p->return_data.month = nowtime.month;p->return_data.day = nowtime.day;break;}p = p->next;}int f;f = write_br_data(L, br_data);if (f == 0)printf("写入失败!\n");elseprintf("写入成功!\n");struct Book* bhead = NULL, * bp, * bL;bp = bL = temp_lian_book(bhead);while (bp){if (strcmp(book_id, bp->id) == 0)bp->borrow = bp->borrow - 1;bp = bp->next;}if (write_book_data(bL,book_data) == 0)printf("写入失败!\n");elseprintf("写入成功!\n");struct Reader* rhead = NULL, * rp, * rL;rp = rL = temp_lian_reader(rhead);while (rp){if (strcmp(reader_name, rp->name) == 0)rp->been_borrow = rp->been_borrow - 1;rp = rp->next;}if (write_reader_data(rL,reader_data) == 0)printf("写入失败!\n");elseprintf("写入成功!\n");}p = p->next;}if (flag3 != 1)printf("未找到该书!\n");}}p = p->next;}if (flag1)printf("未找到该用户!\n");system("pause");int flag4;do{system("cls");printf("1.返回上一级\n");printf("0.退出\n");printf("请输入对应编号:");int n;scanf("%d", &n);flag4 = 0;switch (n){case 1: book_liutong();break;case 2: exit_system();break;default: flag4 = 1;}if (flag4 == 1){printf("输入有误,请重新输入!\n");system("pause");}} while (flag4 != 0);
}
struct Jilu* temp_lian_br(struct Jilu* head)
{FILE* fp = fopen(br_data, "r");if (fp != NULL){struct Jilu temp;struct Jilu* current = NULL, * prev = NULL;while (fscanf(fp, "%s %s %d-%d-%d %d-%d-%d", temp.reader_name, temp.book_id, &temp.borrow_data.year, &temp.borrow_data.month, &temp.borrow_data.day, &temp.return_data.year, &temp.return_data.month, &temp.return_data.day) != EOF){current = (struct Jilu*)malloc(sizeof(struct Jilu));strcpy(current->reader_name, temp.reader_name);strcpy(current->book_id, temp.book_id);current->borrow_data.year = temp.borrow_data.year;current->borrow_data.month = temp.borrow_data.month;current->borrow_data.day = temp.borrow_data.day;current->return_data.year = temp.return_data.year;current->return_data.month = temp.return_data.month;current->return_data.day = temp.return_data.day;current->next = NULL;if (head == NULL)head = current;elseprev->next = current;prev = current;}}return head;
}
struct Data current_system_time()
{struct Data temp;struct tm* ti;time_t t;time(&t);ti = localtime(&t);temp.year = ti->tm_year + 1900;temp.month = ti->tm_mon + 1;temp.day = ti->tm_mday;return temp;
}
int write_br_data(struct Jilu* head, const char* wenjian)
{FILE* fp = fopen(br_data, "w");struct Jilu* kill = head;if (fp == NULL)return 0;while (head){fprintf(fp, "%s %s %d-%d-%d %d-%d-%d\n", head->reader_name, head->book_id, head->borrow_data.year, head->borrow_data.month, head->borrow_data.day, head->return_data.year, head->return_data.month, head->return_data.day);head = head->next;}free_br_data(kill);fclose(fp);return 1;
}
void free_br_data(struct Jilu* head)
{struct Jilu* freehead;while (head != NULL){freehead = head;head = head->next;free(freehead);}
}
void book_number_found()
{struct Book* head = NULL, * p, * kill;char temp_id[100];int flag1 = 1;kill = p = temp_lian_book(head);printf("请输入书号:");scanf("%s", temp_id);while (p){if (strcmp(temp_id, p->id) == 0){flag1 = 0;printf("书本名称:");printf("%s\n", p->name);printf("书本作者:");printf("%s\n", p->author);printf("书本出版社:");printf("%s\n", p->press);printf("书本库存:");printf("%d\n", p->have);printf("已借出:");printf("%d\n", p->borrow);printf("相关检索信息:a, b, c");printf("%d %d %d\n", p->p1, p->p2, p->p3);}p = p->next;}if (flag1)printf("未找到该书!\n");system("pause");int flag2;do{system("cls");printf("1.返回上一级\n");printf("0.退出\n");printf("请输入对应编号:");int n;scanf("%d", &n);flag2 = 0;switch (n){case 1: book_management();break;case 0: exit_system();break;default: flag2 = 1;}if (flag2 == 1){printf("输入有误,请重新输入!\n");system("pause");}} while (flag2 != 0);
}
void book_title_found()
{system("cls");char temp_name[100];int head, lengh;int flag1 = 0;printf("请输入你的书名:");scanf("%s", temp_name);struct Key* khead = NULL, * kp = NULL, * kkill;kkill = kp = temp_lian_key(khead, name_data);while (kp){if (strcmp(temp_name, kp->keyword) == 0){flag1 = 1;head = kp->head;lengh = kp->lengh;break;}kp = kp->next;}free_key_data(kkill);if (flag1 != 1)printf("未找到检索表,未找到该书名!\n");else{int count = 0;int flag2 = 0;struct Book* bhead = NULL, * bp = NULL, * bkill;bkill = bp = temp_lian_book(bhead);while (bp){if (strcmp(temp_name, bp->name) == 0){flag2 = 1;count++;printf("书本名称:");printf("%s\n", bp->name);printf("书本作者:");printf("%s\n", bp->author);printf("书本出版社:");printf("%s\n", bp->press);printf("书本库存:");printf("%d\n", bp->have);printf("已借出:");printf("%d\n", bp->borrow);printf("相关检索信息:a, b, c");printf("%d %d %d\n", bp->p1, bp->p2, bp->p3);}if (bp->num == head || count == lengh)break;bp = bp->next;}if (flag2)printf("未找到书!\n");free_book_data(bkill);}system("pause");int flag3;do{system("cls");printf("1.返回上一级\n");printf("0.退出\n");printf("请输入对应编号:");int n;scanf("%d", &n);flag3 = 0;switch (n){case 1: book_management();break;case 0: exit_system();break;default: flag3 = 1;}if (flag3 == 1){printf("输入有误,请重新输入!\n");system("pause");}} while (flag3 != 0);
}
void book_author_found()
{system("cls");char temp_aut[100];int head, lengh;int flag1 = 0;printf("请输入作者:");scanf("%s", temp_aut);struct Key* khead = NULL, * kp = NULL, * kkill;kkill = kp = temp_lian_key(khead, author_data);while (kp){if (strcmp(temp_aut, kp->keyword) == 0){flag1 = 1;head = kp->head;lengh = kp->lengh;break;}kp = kp->next;}free_key_data(kkill);if (flag1 == 0)printf("未找到检索表,未找到该作者!\n");else{int count = 0;int flag2 = 0;struct Book* bhead = NULL, * bp = NULL, * bkill,*p;p =bkill = bp = temp_lian_book(bhead);while (bp){if (strcmp(temp_aut, bp->author) == 0){flag2 = 1;count++;printf("书本名称:");printf("%s\n", bp->name);printf("书本作者:");printf("%s\n", bp->author);printf("书本出版社:");printf("%s\n", bp->press);printf("书本库存:");printf("%d\n", bp->have);printf("已借出:");printf("%d\n", bp->borrow);printf("相关检索信息:a, b, c");printf("%d %d %d\n", bp->p1, bp->p2, bp->p3);}if (bp->num == head || count == lengh)break;bp = bp->next;}if (flag2 != 1)printf("未找到书!\n");free_book_data(bkill);}system("pause");int flag3;do{system("cls");printf("1.返回上一级\n");printf("0.退出\n");printf("请输入对应编号:");int n;scanf("%d", &n);flag3 = 0;switch (n){case 1: book_management();break;case 0: exit_system();break;default: flag3 = 1;}if (flag3 == 1){printf("输入有误,请重新输入!\n");system("pause");}} while (flag3 != 0);
}
void book_press_found()
{system("cls");char temp_pre[100];int head = 0, lengh = 0;int flag1 = 0;printf("请输入出版社:");scanf("%s", temp_pre);struct Key* khead = NULL, * kp = NULL, * kkill;kkill = kp = temp_lian_key(khead, press_data);while (kp){if (strcmp(temp_pre, kp->keyword) == 0){flag1 = 1;head = kp->head;lengh = kp->lengh;break;}kp = kp->next;}free_key_data(kkill);if (flag1 != 1)printf("未找到检索表,未找到该出版社!\n");else{int count = 0;int flag2 = 0;struct Book* bhead = NULL, * bp = NULL, * bkill;bkill = bp = temp_lian_book(bhead);while (bp){if (strcmp(temp_pre, bp->press) == 0){flag2 = 1;count++;printf("书本名称:");printf("%s\n", bp->name);printf("书本作者:");printf("%s\n", bp->author);printf("书本出版社:");printf("%s\n", bp->press);printf("书本库存:");printf("%d\n", bp->have);printf("已借出:");printf("%d\n", bp->borrow);printf("相关检索信息:a, b, c");printf("%d %d %d\n", bp->p1, bp->p2, bp->p3);}if (bp->num == head || count == lengh)break;bp = bp->next;}if (flag2)printf("未找到书!\n");free_book_data(bkill);}system("pause");int flag3;do{system("cls");printf("1.返回上一级\n");printf("0.退出\n");printf("请输入对应编号:");int n;scanf("%d", &n);flag3 = 0;switch (n){case 1: book_management();break;case 0: exit_system();break;default: flag3 = 1;}if (flag3 == 1){printf("输入有误,请重新输入!\n");system("pause");}} while (flag3 != 0);
}
struct Key* temp_lian_key(struct Key* head, const char* wenjian)
{FILE* fp = fopen(wenjian, "r");if (fp != NULL){struct Key temp;struct Key* current = NULL, * prev = NULL;int i = 0;while (fscanf(fp, "%s %d %d", temp.keyword, &temp.head, &temp.lengh) != EOF){current = (struct Key*)malloc(sizeof(struct Key));strcpy(current->keyword, temp.keyword);current->head = temp.head;current->lengh = temp.lengh;current->next = NULL;if (NULL == head)head = current;elseprev->next = current;prev = current;}}else{printf("文件打开失败!\n");exit_system();}return head;
}
void free_key_data(struct Key* head)
{struct Key* freehead;while (head != NULL){freehead = head;head = head->next;free(freehead);}
}

Book.txt

1 1021 数据库 杨艳 人民邮电 10 4 0 0 0
2 1014 数据结构 赵鹏 高等教育 9 7 0 0 0
3 1106 操作系统 金虎 人民邮电 8 6 2 0 0
4 1108 数据结构 高扬 清华大学 7 5 2 0 0
5 1203 程序设计 杨艳 高等教育 9 4 0 1 2
6 2105 数据库 金虎 清华大学 7 3 1 3 4
7 1012 数据结构 杨艳 人民邮电 8 2 4 5 3
8 0109 程序设计 赵鹏 清华大学 9 1 5 2 6

book_aut.txt

杨艳 7 3
赵鹏 8 2
金虎 6 2
高扬 4 1

book_name.txt

数据库 6 2
数据结构 7 3
操作系统 3 1
程序设计 8 2

book_pre.txt

人民邮电 7 3
高等教育 5 2
清华大学 8 3

Br.txt

1 1021 2021-6-23 2021-6-23
1 1021 2021-6-23 2021-6-23
1 1021 2021-6-23 2021-6-23
1 1021 2021-6-23 2021-6-23
1 1021 2021-6-23 2021-6-23
1 1021 2021-6-23 2021-6-23

Reader.txt

1 qq qq qq 10 0
2 w w w 10 0
3 q q q 10 0
4 re re re 10 0
5 sss sss sss 10 0
6 de de de 10 0
7 1 1 1 10 6
8 2 2 2 10 0

User.txt

gy gygy admin
ly lyly lib
lw lwlw reader
qwe qwe reader
ws wss reader
sss sss reader
de de reader
1 1 reader
2 2 reader

把以上文件做成后缀为txt的文件,并且全部放到 D盘的booksystem文件夹中,没有此文件夹请先建立。

图书管理员:账号:ly,密码:lyly
   系统管理员:账号:  gy,  密码:  gygy
   读者:账号:lw,密码:lwlw

图书馆管理系统(详细)(C语言版本)相关推荐

  1. 通讯录管理系统(c语言版本)

    通讯录管理系统 (c语言版本) 一:通讯录基本功能 二:实现代码分析 1:建立文件 2:test.c test.c完整代码 3:contact.c contact.c完整代码 3:contact.h ...

  2. 图书馆管理系统 (C语言)

    图书馆管理系统 (C语言) GitHub 功能框架如下 管理系统主要使用了以下操作 单向链表的创建.增添.删除.遍历.查找.排序. 链表写入文件.从文件读取数据至链表. 密码的隐式输入.输入检测. 注 ...

  3. 图书馆管理系统利用c语言编写,图书馆管理系统 c语言编写.doc

    图书馆管理系统 c语言编写 #include "stdio.h"#include "stdlib.h"#include "conio.h"# ...

  4. 图书馆管理系统(C语言课程设计)

    图书馆管理系统 程序描述:该程序主要采用链表的形式来对书籍进行添加.修改.删除等等一系列操作,系统内含有用户以及管理员两种形式的访问人员,通过用户以及管理员的形式去对于书籍的一些借阅.归还.添加.删除 ...

  5. C++图书馆管理系统 详细代码

    用容器做的,这个是我的弱项,但大体功能都实现. 图书馆信息系统,是一个单用户系统,所以不用考虑有多少种角色. 实现要点: 1.对 图书: 显示图书馆里的全部书籍 按书名查询 按作者查询 按分类查询 对 ...

  6. 图书馆管理系统代码html语言,html图书管理系统

    [实例简介] 完整的前端代码 图书管理系统~~ [实例截图] [核心代码] StudentBookingSystem-master └── StudentBookingSystem-master ├─ ...

  7. 图书馆管理系统(c++语言实现)

    #include<bits/stdc++.h> using namespace std; int shenfen,n; typedef struct Book//这个为借书还书所需要的书籍 ...

  8. c语言课程设计图书馆管理系统例子,C语言课程设计图书馆管理系统源程序

    审计. 消防执法执法工作轮换消防实践执法,晋升,重新培训退休关键时间同步场所审计机制,自我敦促自我约束,消防执法,自我保护. 1.3预防性消防督促当前的消防执法腐败涉及违法执法的呈上升趋势,从近年来的 ...

  9. 图书馆管理系统(C语言实现)

    源代码在这里 1   图书馆管理系统(C语言实现). 2  功能相对简单, 增删改查而已. 3  详细的介绍都在链接里了. 转载于:https://www.cnblogs.com/zzusunjs/p ...

  10. SSM项目图书馆管理系统,适合新人练手和毕设参考,功能首页展示 系统注册登录登出 用户管理 权限控制管理 书籍管理 图书借阅管理 个人借阅记录管理 书籍详细信息展示等

    图书馆管理系统,系统采用B/S架构 系统采用框架:java+maven+stringboot+mybatis+mysql-plus+boostart(前端界面) 首页展示 内容后台管理 菜单权限管理 ...

最新文章

  1. php错误提示如何查询,php-如何显示我的MySQLi查询错误?
  2. 位宽512bit显卡_显卡知识:关于显卡位宽的基础知识科普
  3. yolov3的缺点_YOLOv3:训练自己的数据(附优化与问题总结)
  4. PowerShell自动删除过期数据
  5. XML fragments parsed from previous mappers already contains value for xxxxx
  6. Maven web项目的项目如何创建
  7. Julia的学习资料从哪里找?
  8. 谈java之GUI与安卓
  9. unityAPI文档离线下载
  10. 数据结构C语言版第二版答案 严蔚敏 李冬梅 吴伟民 编著
  11. linux卸载apache服务器,centos 7 安装卸载apache(httpd)服务的详细步骤
  12. arduino 有源 蜂鸣器_(二十)arduino入门:蜂鸣器的使用
  13. liunx下用xshell实现 密钥 + 密码 登录
  14. 华硕服务器主板安装系统提示驱动,肿么安装电脑的主板芯片组驱动程序步骤华硕主板intel芯片...
  15. 高精度ua级恒流源_一种高精度可调恒流源电路的制作方法
  16. SAP PO750 Process Orchestration 安装及初始化(刘欣)
  17. 青山绿水一枝花...
  18. java毕业设计校园社区系统mybatis+源码+调试部署+系统+数据库+lw
  19. 显卡算力表-arch-架构
  20. 2017年腾讯移动客户端开发岗位电话面试

热门文章

  1. CSS3火焰文字特效制作教程
  2. Kaldi的安装与测试
  3. 贵州大学计算机学院院长,贵州大学计算机科学与信息学院第七届研究生会干部选举大会...
  4. 关于DBF文件格式的详细说明
  5. asterisk cdr mysql_asterisk cdr写入mysql为空的解决办法
  6. 7-36 韩信点兵 (10分)
  7. 曙光服务器怎么修改启动项,简单易上手 戴尔T5500工作站BIOS全设置
  8. 五大特色展区抢占C位,2019深圳国际全触与显示展引燃触控显示产业未来
  9. 对YOLO bounding box的理解
  10. kafka的topic管理常用命令