概述
主要包括圖書的庫存信息,每一本書的借閱信息以及每個人的借書信息。
系統功能:
(1)借閱資料管理(對相關資料進行添加,刪除,修改,查詢等操做)
(2)借閱管理(包括借出操做,還書操做)
(3)讀者管理(讀者等級:可分爲教師,學生。並定義每類讀者可借書數量)
(4)統計分析(當前借閱和相關資料狀態。統計分析借閱排行榜,資料狀態統計,借閱統計,顯示全部至當日到期未還書信息等功能分析)ios
若是以爲鏈表麻煩的話能夠使用(數組+文件):https://blog.csdn.net/qq_30253757/article/details/85341155數據庫
管理員用戶名和密碼都是adminwindows
#include <iostream> #include <cstdio> #include <cstring> #include <string> #include <cmath> #include <cstring> #include <windows.h> #include <ctime> #include <cstdlib> using namespace std; typedef struct books //書籍編號————(做者,名稱,出版時間,價格)與書籍編號一一對應,不然爲新一類書 { //數量 int book_id; char author[50], book_name[50]; int time, count; double price; struct books *next; } BOOK, *Pbook; typedef struct have_been_borrowed //已借出的圖書信息,書籍編號,借書編號,借書數量,書名,所借人的帳號名 { int book_id; int borrowed_book_id; int count; char book_name[50]; char student_id[50]; struct have_been_borrowed *next; } BORROW, *Pborrow; typedef struct users //用戶信息:用戶id,帳戶名,密碼,所借書的上限 { long long int user_id; char user_name[50]; char passwd[50]; int book_limit; int job; struct users *next; } USERS, *Pusers; Pusers user_now = NULL; /**************************如下爲函數聲明**********************************/ void user_error(); //無用戶信息的錯誤提示 int read_books_information_to_file(Pbook head, Pborrow head2, Pusers head3); //文件的讀取 void welcome(); //歡迎界面 void null_error(); //圖書庫爲空的報錯信息 void list_borrow(Pborrow head); //打印已借圖書信息 void addbook(struct books *head); //添加書籍信息 void list(Pbook head); //打印全部書籍信息 int search(Pbook head); //搜尋書籍信息 int modify(Pbook p); //搜尋結束後可進行查找 int del(Pbook before, Pbook will_be_del); //刪除該圖書信息 int borrow(Pbook head, Pborrow borrowed); //借書功能 void return_book_list(Pborrow head, Pbook origin); //還書的列表(便於控制函數的調用) int return_book(Pborrow head_list, Pbook origin); //還書功能 int return_book_by_student_id(Pborrow head, Pbook origin); //經過學號還書 void add_borrow(Pbook d, Pborrow head, int a, int b, int c, char name[], char book_name[]); //已借的書的添加 void borrowor(Pbook head, Pborrow borrowed); //借書菜單 void del_user(Pusers head); //刪除用戶 int add_users(Pusers head); //增長用戶 void user_list(Pusers head); //打印全部用戶信息 int user_manage(Pusers head); //用戶管理主列表 int save_books_information_to_file(Pbook head, Pborrow head2, Pusers head3); //文件的保存 /**************************以上爲函數聲明**********************************/ /***************************圖書基礎功能***********************************/ int read_books_information_to_file(Pbook head, Pborrow head2, Pusers head3) { FILE *p = fopen("books_information.dat", "r"), *q = fopen("borrowed_books.dat", "r"); FILE *u = fopen("users_information.dat", "r"); if (p == NULL || q == NULL || u == NULL) { cout << "文件不存在。。。" << endl << "已重建相關文件" << endl; system("pause"); system("cls"); return 1; } Pbook books_head = head; Pborrow borrowed_head = head2; Pusers users_head = head3; int a, b, k; char name[50]; char author[50]; double price; while (fscanf(p, "%d%s%s%d%lf%d", &a, name, author, &k, &price, &b) != EOF) { Pbook before = (Pbook)malloc(sizeof(BOOK)); before->book_id = a; strcpy(before->book_name, name); strcpy(before->author, author); before->count = b; before->time = k; before->price = price; books_head->next = before; before->next = NULL; books_head = before; } int c, d, e; char borrow_name[50]; char student_id[50]; while (fscanf(q, "%d%s%d%d%s", &c, borrow_name, &d, &e, &student_id) != EOF) { Pborrow after = (Pborrow)malloc(sizeof(BORROW)); after->book_id = c; strcpy(after->book_name, borrow_name); after->borrowed_book_id = d; after->count = e; strcpy(after->student_id, student_id); borrowed_head->next = after; after->next = NULL; borrowed_head = after; } long long user_id; char user_name[50]; char passwd[50]; int book_limit; int job; while (fscanf(u, "%lld%s%s%d%d", &user_id, user_name, passwd, &book_limit,&job) != EOF) { Pusers english = (Pusers)malloc(sizeof(USERS)); english->user_id = user_id; strcpy(english->user_name, user_name); strcpy(english->passwd, passwd); english->book_limit = book_limit; english->job=job; users_head->next = english; english->next = NULL; users_head = english; } fclose(p); fclose(q); fclose(u); return 0; } int save_books_information_to_file(Pbook head, Pborrow head2, Pusers head3) { system("cls"); FILE *p = fopen("books_information.dat", "w"); FILE *bore = fopen("borrowed_books.dat", "w"); FILE *u = fopen("users_information.dat", "w"); if (p == NULL ) { cout << "打開文件失敗!!!,請重試。。。" << endl; return 1; } if ( bore == NULL) { cout << "打開文件失敗!!!,請重試。。。" << endl; return 1; } if ( u == NULL) { cout << "打開文件失敗!!!,請重試。。。" << endl; return 1; } Pbook q = head->next; Pborrow w = head2->next; Pusers eng = head3->next; cout << "正在寫入文件,請稍後。。。" << endl; Sleep(1500); while (q != NULL) { fprintf(p, "%d %s %s %d %f %d\n", q->book_id, q->book_name, q->author, q->time, q->price, q->count); q = q->next; } while (w != NULL) { fprintf(bore, "%d %s %d %d %s\n", w->book_id, w->book_name, w->borrowed_book_id, w->count, w->student_id); w = w->next; } while (eng != NULL) { fprintf(u, "%lld %s %s %d %d\n", eng->user_id, eng->user_name, eng->passwd, eng->book_limit,eng->job); eng = eng->next; } system("cls"); cout << "寫入完成。請稍後。。。" << endl; fclose(p); fclose(bore); fclose(u); return 0; } void list_borrow(Pborrow head) { if (head->next == NULL) { system("cls"); cout << "數據庫無借閱信息" << endl; cout << "請按回車退出 。。。" << endl; getchar(); getchar(); return; } system("cls"); for (int i = 0; i < 56; i++) printf("*"); printf("\n"); printf("* %11s", "借閱編號"); printf("%11s", "圖書編號"); printf("%10s", "借閱數量"); printf("%18s *\n", "借閱者帳號"); Pborrow p = head->next; while (p != NULL) { printf("* %11d", p->borrowed_book_id); printf("%11d", p->book_id); printf("%10d", p->count); printf("%18s *\n", p->student_id); p = p->next; } for (int i = 0; i < 56; i++) printf("*"); cout << endl << "輸入回車繼續。。。" << endl; getchar(); getchar(); system("cls"); } void addbook(struct books *head) { int id, time, count; char name[50], author[50]; double price; struct books *q = head; while (1) { system("cls"); cout << "請輸入書籍編號" << endl; cin >> id; cout << "請輸入書籍名稱" << endl; scanf("%s", name); cout << "請輸入做者名字" << endl; scanf("%s", author); cout << "請輸入出版時間" << endl; cin >> time; cout << "請輸入書籍價格" << endl; cin >> price; cout << "請輸入書籍數量" << endl; cin >> count; while (q->next != NULL) { if (id == q->next->book_id && strcmp(name, q->next->book_name) == 0 && strcmp(author, q->next->author) == 0) { if (time == q->next->time && price == q->next->price) { q->next->count += count; system("cls"); cout << "圖書添加成功。。。" << endl; Sleep(1000); system("cls"); break; } } q = q->next; } if (q->next == NULL) { struct books *p; p = (struct books *)malloc(sizeof(struct books)); q->next = p; p->next = NULL; p->book_id = id; p->count = count; p->price = price; p->time = time; strcpy(p->book_name, name); strcpy(p->author, author); cout << "圖書添加成功。。。" << endl; Sleep(1000); } system("cls"); int in; cout << "是否要繼續?" << endl << "*****************" << endl << "* 1.繼續 *" << endl << "* 0.結束 *" << endl << "*****************" << endl; cin >> in; if (in == 0) return; } } void null_error() { system("cls"); cout << "數據庫無圖書信息,請先添加圖書信息" << endl; cout << "請按回車退出搜索。。。" << endl; system("pause"); } void list(Pbook head) { if (head->next == NULL) { null_error(); return; } system("cls"); for (int i = 0; i < 70; i++) printf("*"); printf("\n"); printf("* %8s", "圖書編號"); printf("%14s", "圖書名稱"); printf("%10s", "做者"); printf("%14s", "時間"); printf("%10s", "價格"); printf("%10s *\n", "數量"); Pbook p = head->next; while (p != NULL) { printf("* %8d", p->book_id); printf("%14s", p->book_name); printf("%10s", p->author); printf("%14d", p->time); printf("%10.2f", p->price); printf("%10d *\n", p->count); p = p->next; } for (int i = 0; i < 70; i++) printf("*"); cout << endl << "輸入回車繼續。。。" << endl; system("pause"); system("cls"); } /*************************圖書查找,修改,刪除功能區*******************************/ int search(Pbook head) { int want_to_search, flag; while (1) { Pbook p = head->next, before = head; flag = 0; if (head->next == NULL) { null_error(); return 0; } system("cls"); cout << "請輸入要搜索的圖書編號:"; cin >> want_to_search; system("cls"); cout << "正在尋找,請稍後。。。"; while (p != NULL) { if (p->book_id == want_to_search) { system("cls"); flag = 1; break; } before = p; p = p->next; } if (flag == 0) { system("cls"); cout << "未查找到相應圖書信息\n"; cout << "接下來要作什麼?" << endl << "\t1.繼續查找" << endl << "\t0.結束" << endl; int in; cin >> in; if (in == 1) continue; else return 0; } else { int in; system("cls"); cout << "已找到相關圖書,接下來要作什麼?" << endl; while (1) { int flag1 = 0; cout << "******************************" << endl; cout << "* 1.打印相關圖書信息 *" << endl; cout << "* 2.對相關圖書進行修改 *" << endl; cout << "* 3.刪除該圖書信息 *" << endl; cout << "* 4.繼續查找 *" << endl; cout << "* 0.退出 *" << endl; cout << "******************************" << endl; cin >> in; switch (in) { case 1: system("cls"); for (int i = 0; i < 70; i++) printf("*"); printf("\n* %8s", "圖書編號"); printf("%14s", "圖書名稱"); printf("%10s", "做者"); printf("%14s", "時間"); printf("%10s", "價格"); printf("%10s *\n", "數量"); printf("* %8d", p->book_id); printf("%14s", p->book_name); printf("%10s", p->author); printf("%14d", p->time); printf("%10.2f", p->price); printf("%10d *\n", p->count); for (int i = 0; i < 70; i++) printf("*"); cout << endl << "輸入以回車繼續。。。"; getchar(); getchar(); system("cls"); flag = 0; break; case 2: if (modify(p) == 1) { flag1 = 1; break; } else { flag1 = 0; break; } case 3: if (del(before, p) == 1) { return 1; } else { return 0; } case 4: flag1 = 1; break; case 0: return 0; } if (flag1 == 1) break; else { system("cls"); cout << "還須要作什麼?" << endl; continue; } } } } } int del(Pbook before, Pbook will_be_del) { before->next = will_be_del->next; free(will_be_del); system("cls"); cout << "該圖書信息已被刪除" << endl << "你還須要作什麼?" << endl; while (1) { cout << "**********************" << endl << "* 1.繼續搜索 *" << endl << "* 0.退出搜索 *" << endl << "**********************" << endl; int in; cin >> in; if (in == 1) { return 1; } else if (in == 0) return 0; else { cout << "輸入錯誤,請從新選擇" << endl; continue; } } } int modify(Pbook p) { system("cls"); cout << "您須要作什麼?" << endl; int in; while (1) { cout << "*************************" << endl; cout << "* 1.修改圖書名稱 *" << endl; cout << "* 2.修改做者 *" << endl; cout << "* 3.修改出版時間 *" << endl; cout << "* 4.修改價格 *" << endl; cout << "* 5.修改數量 *" << endl; cout << "* 6.回到上一目錄 *" << endl; cout << "* 0.退出 *" << endl; cout << "*************************" << endl; cin >> in; system("cls"); switch (in) { case 1: cout << "原有的圖書名稱爲:" << p->book_name << endl << "請鍵入修改後的名稱:"; scanf("%s", p->book_name); break; case 2: cout << "原有的做者爲:" << p->author << endl << "請鍵入修改後的做者:"; scanf("%s", p->author); break; case 3: cout << "原有的出版時間爲:" << p->time << endl; cout << "請鍵入修改後的時間:"; cin >> p->time; break; case 4: cout << "原有的價格爲:" << p->price << endl; cout << "請鍵入修改後的價格:"; cin >> p->price; break; case 5: cout << "原有的數量爲:" << p->count << endl; cout << "請鍵入修改後的數量:"; cin >> p->count; break; case 6: return 0; break; case 0: return 1; break; } system("cls"); cout << "信息修改爲功,按回車繼續。。。" << endl; system("pause"); system("cls"); cout << "您還須要作什麼?" << endl; } } /************************************借閱功能區**************************************************/ void borrowor(Pbook head, Pborrow borrowed) { system("cls"); if (head->next == NULL) { null_error(); return; } int in; cout << "您要作什麼" << endl; while (1) { cout << "***************************" << endl << "* 1.借閱圖書 *" << endl << "* 2.歸還圖書 *" << endl << "* 0.退出 *" << endl << "***************************" << endl; cin >> in; int tsl; switch (in) { case 1: tsl = borrow(head, borrowed); while (tsl != 0) { tsl = borrow(head, borrowed); } break; case 2: return_book_list(borrowed, head); break; case 0: return; } system("cls"); cout << "您還須要作什麼?" << endl; } } int borrow(Pbook head, Pborrow borrowed) { system("cls"); cout << "請輸入搜尋根據" << endl; cout << "*************************" << endl << "* 1.圖書編號 *" << endl << "* 2.圖書名稱 *" << endl << "* 3.圖書做者 *" << endl << "* 0.退出 *" << endl << "*************************" << endl; int in; cin >> in; system("cls"); int want_to_find_num; char want_to_find_name[50]; char want_to_find_author[50]; switch (in) { case 1: cout << "請輸入圖書編號:"; cin >> want_to_find_num; break; case 2: cout << "請輸入圖書名稱:"; cin >> want_to_find_name; break; case 3: cout << "請輸入圖書做者:"; cin >> want_to_find_author; break; case 0: return 0; } Pbook p = head->next; int flag2 = 0; while (p != NULL) { switch (in) { case 1: if (want_to_find_num == p->book_id) flag2 = 1; break; case 2: if (strcmp(want_to_find_name, p->book_name) == 0) flag2 = 1; break; case 3: if (strcmp(want_to_find_author, p->author) == 0) flag2 = 1; break; } if (flag2 == 1) break; p = p->next; } if (flag2 == 0) { system("cls"); cout << "未找到相關圖書,是否借閱其它圖書?" << endl; cout << "********************" << endl << "* 1.繼續 *" << endl << "* 0.結束 *" << endl << "********************" << endl; int intwice; cin >> intwice; if (intwice == 1) return 1; else return 0; } else { system("cls"); if (p->count == 0) { cout << "該圖書暫時缺貨" << endl << "****************" << endl << "* 1.繼續借閱 *" << endl << "* 0.退出 *" << endl << "****************" << endl; int in; cin >> in; if (in == 1) return 1; else return 0; } cout << "已找到該圖書,"; while (1) { cout << "目前此書還有" << p->count << "本" << endl << "你如今還能夠借閱" << user_now->book_limit << "本書" << endl << "請輸入借閱數量(輸入0爲取消借閱):" << endl; int borrow_count; cin >> borrow_count; system("cls"); if (borrow_count > p->count) { cout << "沒這麼多書!!!" << endl << "************************" << endl << "* 1.輸入其餘數量 *" << endl << "* 2.借閱其餘圖書 *" << endl << "* 0.取消借閱 *" << endl << "************************" << endl; int choose_book; cin >> choose_book; if (choose_book == 2) return 1; else if (choose_book == 0) return 0; else { system("cls"); continue; } } else { p->count -= borrow_count; user_now->book_limit -= borrow_count; add_borrow(p, borrowed, p->book_id, p->book_id * 10000 + p->count, borrow_count, user_now->user_name, p->book_name); cout << "借閱成功,請按時歸還。" << endl << "輸入回車以繼續。。。"; getchar(); return 0; } system("cls"); } } return 0; } void add_borrow(Pbook d, Pborrow head, int a, int b, int c, char name[], char book_name[]) { Pborrow p = head; while (p->next != NULL) p = p->next; Pborrow q = (Pborrow)malloc(sizeof(BORROW)); q->book_id = a; strcpy(q->book_name, book_name); q->borrowed_book_id = b; q->count = c; strcpy(q->student_id, name); p->next = q; q->next = NULL; cout << "請記錄您的借書編號:" << b << endl; cout << "請按下回車繼續。。。"; getchar(); getchar(); system("cls"); return; } void return_book_list(Pborrow head, Pbook origin) { system("cls"); cout << "請選擇:" << endl << "**************************" << endl << "* 1.經過學號還書 *" << endl << "* 2.經過編號還書 *" << endl << "* 0.退出 *" << endl << "**************************" << endl; int in; cin >> in; system("cls"); if (in == 1) { return_book_by_student_id(head, origin); } else if (in == 2) { return_book(head, origin); } else return; } int return_book_by_student_id(Pborrow head, Pbook origin) { system("cls"); char student_id[50]; int flag = 0; cout << "請輸入您的賬號:"; cin >> student_id; system("cls"); Pborrow p = head->next; while (p != NULL) { if (strcmp(p->student_id, student_id) == 0) { if (flag == 0) { flag = 1; cout << "****************************************************************" << endl << "* 借書編號 書籍名稱 借書數量 借書者學號 *" << endl; } printf("*%10d", p->borrowed_book_id); printf("%14s", p->book_name); printf("%14d", p->count); printf("%18s *\n", p->student_id); } p = p->next; } if (flag == 1) { cout << "****************************************************************" << endl; return_book(head, origin); return 0; } else { system("cls"); cout << "您沒有借過書" << endl << "按下回車繼續。。。" << endl; getchar(); getchar(); system("cls"); return 0; } } int return_book(Pborrow head_list, Pbook origin) { int return_id; cout << "請輸入您的借書編號以還書(輸入0取消還書):"; cin >> return_id; if (return_id == 0) { system("cls"); cout << "取消成功" << endl; system("pause"); return 0; } int flag = 0; Pborrow p = head_list->next, before = head_list; while (p != NULL) { if (p->borrowed_book_id == return_id) { flag = 1; break; } before = p; p = p->next; } system("cls"); if (flag == 0) { cout << "借書編號有誤,請從新輸入" << endl; cout << "按下回車繼續"; getchar(); getchar(); system("cls"); return 1; } else { origin->count += p->count; user_now->book_limit += p->count; before->next = p->next; free(p); cout << "歸還成功。。。"; Sleep(2000); system("cls"); } return 0; } int fix_passwd_by_oneself() { system("cls"); while (1) { cout << "請輸入修改後的密碼:"; char passwd_now[50], again[50]; cin >> passwd_now; cout << "請再次輸入密碼:"; cin >> again; if (strcmp(passwd_now, again) == 0) { strcpy(user_now->passwd, passwd_now); cout << "密碼修改爲功。。。" << endl; system("pause"); return 0; } else { cout << "兩次輸入密碼不一致。。。" << endl; system("pause"); } } } /*****************************************用戶管理***********************************************/ char administrator[50] = "admin"; char admin_passwd[50] = "admin"; int user_judge(Pusers head) { system("cls"); char user_id[50]; cout << "請輸入您的帳號:"; cin >> user_id; if (strcmp(administrator, user_id) == 0) { cout << "請輸入密碼:"; char passwd[50]; cin >> passwd; if (strcmp(passwd, admin_passwd) == 0) return 2; //權限爲2,即最高權限————管理員 } Pusers p = head->next; while (p != NULL) { if (strcmp(p->user_name, user_id) == 0) { char passwd[50]; cout << "請輸入密碼:"; cin >> passwd; int count_limit = 3; while (count_limit--) { if (strcmp(passwd, p->passwd) == 0) { user_now = p; return 1; } //權限爲1,爲用戶權限 } return 0; //權限爲0,即未登陸,沒有權限 } p = p->next; } cout << "暫未收錄該用戶信息,請聯繫管理員。。。" << endl; system("pause"); return 0; } void user_error() { system("cls"); cout << "暫未收錄任何用戶信息" << endl; system("pause"); } void del_user(Pusers head) { if (head->next == NULL) { user_error(); return; } cout << "請輸入要註銷用戶編號:"; long long id; cin >> id; Pusers p = head; while (p->next != NULL) { if (id == p->user_id) { break; } p = p->next; } if (p->next == NULL) { cout << "該用戶不存在。。。" << endl; system("pause"); return; } p->next = p->next->next; free(p->next); cout << "用戶刪除成功。。。" << endl; system("pause"); return; } int add_users(Pusers head) { system("cls"); Pusers p = head; while (p->next != NULL) { p = p->next; } while (1) { system("cls"); Pusers q = (Pusers)malloc(sizeof(USERS)); p->next = q; q->next = NULL; char idid[50]; int flag = 1; while (flag) { cout << "請輸入用戶編號(編號爲數字):"; cin >> idid; q->user_id=0; long long ten=1; for (int i = strlen(idid)-1; i >=0 ; i--) { if (idid[i] >= '0' && idid[i] <= '9') { q->user_id +=( idid[i] - '0')*ten; flag = 0; ten*=10; } else { flag = 1; break; } } if (flag == 1) { system("cls"); cout << "編號爲數字!!!" << endl; cout << "編號爲數字!!!" << endl; cout << "編號爲數字!!!" << endl; system("pause"); system("cls"); } } flag = 1; while (flag) { cout << "請輸入帳號:"; scanf("%s", q->user_name); if (strcmp(q->user_name, "admin") == 0) { cout << "帳號不能爲admin" << endl; system("pause") } Pusers chongfu = head->next; while (chongfu != NULL) { if (strcmp(q->user_name, chongfu->user_name) == 0) { break; } } if (chongfu == NULL) { flag = 0; } else { cout << "用戶名已存在" << endl; system("pause"); system("cls"); } } cout << "請輸入密碼:"; scanf("%s", q->passwd); cout << "用戶身份:" << endl << "1.學生" << endl << "2.老師" << endl; int job; cin >> job; q->book_limit = job * 10; q->job=job; p->next = q; p = p->next; system("cls"); cout << "添加成功。。。" << endl; system("pause"); system("cls"); cout << "是否繼續添加?" << endl << "1.是" << endl << "0.否" << endl; cin >> job; system("cls"); if (job == 0) { return 0; } } } void user_list(Pusers head) { system("cls"); if (head->next == NULL) { user_error(); return; } Pusers p = head->next; printf("%10s%16s%16s\n", "用戶編號", "用戶名", "身份"); while (p != NULL) { char job[50]; if (p->job == 1) { strcpy(job, "學生"); } else strcpy(job, "老師"); printf("%10d", p->user_id); printf("%16s", p->user_name); printf("%16s\n", job); p = p->next; } system("pause"); system("cls"); } int user_manage(Pusers head) { system("cls"); cout << "1.增長用戶" << endl << "2.註銷用戶" << endl << "3.全部用戶" << endl << "0.退出" << endl; cout << "請選擇:"; int in; cin >> in; switch (in) { case 1: add_users(head); break; case 2: del_user(head); break; case 3: user_list(head); break; case 0: return 0; } } /*****************************************主函數區***********************************************/ void welcome(int root) { if (root == 1) { cout << "1.全部圖書" << endl << "2.借還圖書" << endl << "3.更改密碼" << endl << "0.退出" << endl; } else if (root == 2) { cout << "1.增長圖書" << endl << "2.全部圖書" << endl << "3.搜索圖書" << endl << "4.用戶管理" << endl << "5.查看全部已借圖書" << endl << "0.退出" << endl; } printf("請輸入相應序號:"); } int main() { int n; BOOK headd; BORROW borrowedd; Pbook head = &headd; Pborrow borrowed = &borrowedd; USERS user_head; Pusers puser = &user_head; headd.next = NULL; borrowedd.next = NULL; user_head.next = NULL; read_books_information_to_file(head, borrowed, puser); int root = user_judge(puser); system("cls"); while (root == 0) { cout << "\t1.繼續登錄" << endl << "\t0.退出" << endl; cout << "\t請選擇:"; int in; cin >> in; if (in == 0) { cout << "感謝使用。。。" << endl; Sleep(1000); return 0; } else { root = user_judge(puser); } } welcome(root); int ffllaagg; if (root == 1) //普通用戶選項 { while (cin >> n) { if (n == 0) { system("cls"); // cout << "感謝您的使用." << endl; break; ; } switch (n) { case 1: list(head); break; case 2: borrowor(head, borrowed); break; case 3: fix_passwd_by_oneself(); break; } system("cls"); cout << "你還要作什麼:" << endl; welcome(root); } } else if (root == 2) { while (cin >> n) { if (n == 0) { system("cls"); // cout << "感謝您的使用." << endl; break; ; } switch (n) { case 1: addbook(head); break; case 2: list(head); break; case 3: ffllaagg = search(head); while (ffllaagg) { ffllaagg = search(head); } break; case 4: user_manage(puser); break; case 5: list_borrow(borrowed); break; } system("cls"); cout << "您還須要作什麼" << endl; welcome(root); } } system("cls"); save_books_information_to_file(head, borrowed, puser); system("pause"); return 0; }