From 862c5ad32171afe10e176f6523f9b89f1ff5a786 Mon Sep 17 00:00:00 2001 From: liucaiyue <3243397663@qq.com> Date: Sun, 16 Apr 2023 16:07:58 +0800 Subject: [PATCH 01/26] teammates --- teammates | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/teammates b/teammates index 4d6c713..7d4e072 100644 --- a/teammates +++ b/teammates @@ -1,4 +1,5 @@ 杨腾泽 孙英皓 刘彩月 -李聪颖 \ No newline at end of file +李聪颖 +hello world \ No newline at end of file From 03d161052f865b979fcef51f67ac00236adee835 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E8=81=AA=E9=A2=96?= <3139769854@qq.com> Date: Sun, 16 Apr 2023 16:33:35 +0800 Subject: [PATCH 02/26] okok --- teammates | 1 - 1 file changed, 1 deletion(-) diff --git a/teammates b/teammates index 4d6c713..028263d 100644 --- a/teammates +++ b/teammates @@ -1,4 +1,3 @@ 杨腾泽 孙英皓 刘彩月 -李聪颖 \ No newline at end of file From a09b5b7aae7edb55a3ea7e9b0fee4a9aed64c23c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=BD=A9=E6=9C=88?= <3243397663@qq.com> Date: Sun, 16 Apr 2023 16:34:26 +0800 Subject: [PATCH 03/26] teammates --- teammates | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/teammates b/teammates index 7d4e072..ffc71e8 100644 --- a/teammates +++ b/teammates @@ -2,4 +2,5 @@ 孙英皓 刘彩月 李聪颖 -hello world \ No newline at end of file +hello world +goodbye \ No newline at end of file From d6b7d4792497e2c0d176f8f891a0f5439dbc8ddf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E8=81=AA=E9=A2=96?= <3139769854@qq.com> Date: Sun, 16 Apr 2023 16:39:18 +0800 Subject: [PATCH 04/26] okk --- teammates | 1 + 1 file changed, 1 insertion(+) diff --git a/teammates b/teammates index 028263d..4d6c713 100644 --- a/teammates +++ b/teammates @@ -1,3 +1,4 @@ 杨腾泽 孙英皓 刘彩月 +李聪颖 \ No newline at end of file From cfe3cd38452aed272345a89928461218b3fa1fe8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E8=81=AA=E9=A2=96?= <3139769854@qq.com> Date: Sun, 16 Apr 2023 16:41:43 +0800 Subject: [PATCH 05/26] 1 --- teammates | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/teammates b/teammates index 4d6c713..8ae1d10 100644 --- a/teammates +++ b/teammates @@ -1,4 +1,4 @@ 杨腾泽 孙英皓 刘彩月 -李聪颖 \ No newline at end of file +李聪颖1 \ No newline at end of file From 7111b608c3951bfbe57cedd61f95502d13432f95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=BD=A9=E6=9C=88?= <3243397663@qq.com> Date: Sun, 16 Apr 2023 16:47:21 +0800 Subject: [PATCH 06/26] teammates --- teammates | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/teammates b/teammates index ffc71e8..23f251c 100644 --- a/teammates +++ b/teammates @@ -3,4 +3,5 @@ 刘彩月 李聪颖 hello world -goodbye \ No newline at end of file +goodbye +qwertyuiop \ No newline at end of file From 40555f68ebda83d402267c7213d191adcd562d8a Mon Sep 17 00:00:00 2001 From: p253vfkpe <3243397663@qq.com> Date: Sun, 16 Apr 2023 16:56:57 +0800 Subject: [PATCH 07/26] Update xiaoming.md --- xiaoming.md | 1 + 1 file changed, 1 insertion(+) diff --git a/xiaoming.md b/xiaoming.md index a9a22e6..61ad311 100644 --- a/xiaoming.md +++ b/xiaoming.md @@ -1 +1,2 @@ +AAAA AAAA \ No newline at end of file From a4a11127ea839547c533f65f46808539dbb404bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E8=81=AA=E9=A2=96?= <3139769854@qq.com> Date: Sun, 16 Apr 2023 17:03:28 +0800 Subject: [PATCH 08/26] 2 --- teammates | 3 --- 1 file changed, 3 deletions(-) diff --git a/teammates b/teammates index 5886794..b8b24f6 100644 --- a/teammates +++ b/teammates @@ -1,10 +1,7 @@ 杨腾泽 孙英皓 刘彩月 -<<<<<<< HEAD 李聪颖1 -======= 李聪颖 hello world goodbye ->>>>>>> a879cff355118113df8336ccf49727504b5d553a From d291aa2d445def4b9be6692f8ba4fd996d08db54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E8=85=BE=E6=B3=BD?= Date: Sun, 16 Apr 2023 17:44:38 +0800 Subject: [PATCH 09/26] teammates --- teammates | 4 ---- 1 file changed, 4 deletions(-) diff --git a/teammates b/teammates index aab0e12..1bc9920 100644 --- a/teammates +++ b/teammates @@ -1,8 +1,4 @@ 杨腾泽 孙英皓 刘彩月 -李聪颖1 李聪颖 -hello world -goodbye -qwertyuiop From 2fcae1b27a7f7e03ec17c4e69cb65acea5aa6391 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E8=85=BE=E6=B3=BD?= Date: Sun, 16 Apr 2023 17:47:32 +0800 Subject: [PATCH 10/26] 1 --- teammates | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/teammates b/teammates index 1bc9920..ed9ecba 100644 --- a/teammates +++ b/teammates @@ -1,4 +1,4 @@ -杨腾泽 +杨腾泽1 孙英皓 刘彩月 李聪颖 From 452d8bece6dbda7ff2ff113dd9fb7ea253acca72 Mon Sep 17 00:00:00 2001 From: pkcs2aq9m Date: Fri, 21 Apr 2023 22:36:35 +0800 Subject: [PATCH 11/26] Delete 'book.cpp' --- book.cpp | 170 ------------------------------------------------------- 1 file changed, 170 deletions(-) delete mode 100644 book.cpp diff --git a/book.cpp b/book.cpp deleted file mode 100644 index abb721f..0000000 --- a/book.cpp +++ /dev/null @@ -1,170 +0,0 @@ -#include -using namespace std; - -#include "sqlist.h" // 顺序表 - -// 图书信息 -struct Book { - int id; // 编号 - string title; // 标题 - string author; // 作者 - float price; // 价格 -}; - -// 所有书的列表 -SqList books; - -int get_command(); // 读取命令 -void DoAddBook(); // 添加图书 -void DoFindBook(); // 查找图书 -void DoDeleteBook(); // 删除图书 -void DoPrintBook(); // 打印图书 - -int main() -{ - bool finish = false; - - InitList(books); - - while (!finish) { - switch (get_command()) { - case 1: // Add book - DoAddBook(); - break; - case 2: // Find book - DoFindBook(); - break; - case 3: // Delete book - DoDeleteBook(); - break; - case 4: // Print - DoPrintBook(); - break; - case 0: // Exit - finish = true; - break; - default: // no command - cout << "Error command." << endl; - } - } - - DestroyList(books); - - return 0; -} - -// 读取命令 -int get_command() -{ - int cmd; - cout << "Commands: (1) Add, (2) Find, (3) Delete, (4) Print, (0) Exit\n"; - cout << "Enter your choice (0-4): "; - cin >> cmd; - return cmd; -} - -// 输入一本书的信息 -void read(Book& b) -{ - cout << "ID : "; - cin >> b.id; - cin.ignore(1024, '\n'); // skip rest chars of the line - cout << "TITLE : "; - getline(cin, b.title); - cout << "AUTHOR: "; - getline(cin, b.author); - cout << "PRICE : "; - cin >> b.price; -} - -// 打印一本书的信息 -void print(const Book& b) -{ - cout << "Book { id: " << b.id << "," - << " title:\"" << b.title << "\"," - << " author: \"" << b.author << "\"," - << " price: " << b.price << " }" - << endl; -} - -// 根据 id 查找图书 -// 若找到,返回元素的位序,找不到时返回 0 -int find(int id) -{ - - for (int i = 1; i <= books.length; i++) - { - if (id == books.elem[i].id){ - return i; - } - } - return 0; // not found -} - -// 添加图书 -void DoAddBook() -{ - Book e; - read(e); - books.elem[books.length + 1] = e; - books.length++; - print(e); - cout << "Added" << endl; -} - -// 查找图书 -void DoFindBook() -{ - int id; - cout << "Enter book ID: "; - cin >> id; - Book e; - - if (find(id) == 0) - cout << "Not found" << endl; - else - { - e = books.elem[find(id)]; - print(e); - cout << "Found" << endl; - } -} - -// 删除图书 -void DoDeleteBook() -{ - int id; - cout << "Enter book ID: "; - cin >> id; - Book e; - int c = find(id); - if (find(id) == 0) - cout << "Not found" << endl; - else - { - e = books.elem[c]; - print(e); - for (int i = c; i < books.length; i++) - { - books.elem[i] = books.elem[i + 1]; - } - --books.length; - cout << "Deleted" << endl; - } -} - -// 打印图书 -void DoPrintBook() -{ - int flag = 0; - for (int i = 0; i < books.length; i++) - { - Book e; - e = books.elem[i + 1]; - print(e); - flag++; - } - cout << "Total: "; - cout << flag; - cout << " books" << endl; -} \ No newline at end of file From 98291f4a11806a519e584d8848978f8a03c95514 Mon Sep 17 00:00:00 2001 From: pkcs2aq9m Date: Fri, 21 Apr 2023 22:36:41 +0800 Subject: [PATCH 12/26] Delete 'data.h' --- data.h | 55 ------------------------------------------------------- 1 file changed, 55 deletions(-) delete mode 100644 data.h diff --git a/data.h b/data.h deleted file mode 100644 index 24e086e..0000000 --- a/data.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef DATA_H_INCLUDED -#define DATA_H_INCLUDED - -#include -// 函数声明 -void read_data(void); // 读取 -void save_data(void); // 保存 -void print_data(void); // 打印 -void query_data(void); // 查询 -void add_data(void); // 添加 -void update_data(void); // 修改 -void delete_data(void); // 删除 -void sort_data(void); // 排序 -void make_chart(void); // 图表 - - -void read_data(void) - { - printf("读取\n"); - } -void save_data(void) - { - printf("保存\n"); - } -void print_data(void) - { - printf("打印\n"); - } -void query_data(void) - { - printf("查询\n"); - } -void add_data(void) - { - puts("添加"); - } -void update_data(void) - { - puts("修改"); - } -void delete_data(void) - { - puts("删除"); - } -void sort_data(void) - { - puts("排序"); - } -void make_chart(void) - { - puts("图表"); - } - - -#endif // DATA_H_INCLUDED \ No newline at end of file From 35d8fad89ba261ad545c0570ddedace0d918a835 Mon Sep 17 00:00:00 2001 From: pkcs2aq9m Date: Fri, 21 Apr 2023 22:36:59 +0800 Subject: [PATCH 13/26] Delete 'sqlist.h' --- sqlist.h | 177 ------------------------------------------------------- 1 file changed, 177 deletions(-) delete mode 100644 sqlist.h diff --git a/sqlist.h b/sqlist.h deleted file mode 100644 index 873a930..0000000 --- a/sqlist.h +++ /dev/null @@ -1,177 +0,0 @@ -/////////////////////////////////////// -/// file: sqlist.h -/// Sequential list -/////////////////////////////////////// - -#pragma once - -#include // for std::out_of_range -using std::out_of_range; // 导入名称 -using std::length_error; - -/////////////////////////////////////// -/// 存储结构 - -/// -/// 线性表的顺序存储结构 -/// -template -struct SqList -{ - E elem[MAXSIZE]; - int length; -}; - -/////////////////////////////////////// -/// 基本操作 - -/// -/// 构造空的顺序表 L -/// -template -void InitList(SqList &L) -{ - L.length = 0; // 空表长度为 0 -} - -/// -/// 销毁顺序表 L -/// -template -void DestroyList(SqList &L) -{ - // do nothing -} - -/// -/// 将顺序表 L 置为空表 -/// -template -void ClearList(SqList &L) -{ - L.length = 0; -} - -/// -/// 若 L 为空表,则返回 true,否则返回 false -/// -template -bool ListEmpty(const SqList &L) -{ - return L.length == 0; -} - -/// -/// 返回顺序表 L 中数据元素个数 -/// -template -int ListLength(const SqList &L) -{ - return L.length; -} - -/// -/// 用 e 返回顺序表 L 中第 i 个数据元素,1<=i<=length -/// -template -bool GetElem(const SqList &L, int i, E &e) -{ - // 若 i 值不合法,则返回 false - if (i < 1 || i > L.length) - return false; - - // 取第 i 个元素 - e = L.elem[i - 1]; - - // 返回 true 表示操作成功 - return true; -} - -/// -/// 取顺序表 L 中第 i 个元素 -/// -template -const E &GetElem(const SqList &L, int i) -{ - // 若 i 值不合法,不能取元素 - if (i < 1 || i > L.length) - throw out_of_range("i out of range"); - - // 返回第 i 个元素 - return L.elem[i - 1]; -} - -/// -/// 在顺序表 L 中第 i 个位置之前插入新的数据元素 e -/// -template -void ListInsert(SqList &L, int i, E e) -{ - // 若表满,则不能插入 - if (L.length == MAXSIZE) - throw length_error("L is full"); - // 若 i 值不合法,则不能插入 - if (i < 1 || i > L.length + 1) - throw out_of_range("i out of range"); - - // 插入位置及之后的元素后移 - for (int j = L.length - 1; j >= i - 1; j--) - { - L.elem[j + 1] = L.elem[j]; - } - // 插入元素 - L.elem[i - 1] = e; - // 表长增 1 - L.length++; -} - -/// -/// 在顺序表 L 中删除第 i 个元素,用 e 返回 -/// -template -void ListDelete(SqList &L, int i, E &e) -{ - // 若 i 值不合法,则不能删除 - if (i < 1 || i > L.length) - throw out_of_range("i out of range"); - - // 取出被删除元素 - e = L.elem[i - 1]; - // 被删除元素之后的元素前移 - for (int j = i; j < L.length; j++) - { - L.elem[j - 1] = L.elem[j]; - } - // 表长减 1 - L.length--; -} - -/// -/// 返回顺序表 L 中第一个与 e 满足关系 compare 的数据元素的位序 -/// 若这样的数据元素不存在,则返回 0。 -/// -template -int LocateElem(const SqList &L, const E &e, Cmp compare) -{ - // 逐个取出元素与 e 比较 - for (int i = 0; i < L.length; i++) - { - // 若满足条件,则返回位序 - if (compare(L.elem[i], e)) - return i + 1; - } - - return 0; // 不存在 -} - -/// -/// 遍历顺序表,依次对 L 中的每个数据元素调用函数 visit -/// -template -void ListTraverse(const SqList &L, Func visit) -{ - for (int i = 0; i < L.length; i++) - { - visit(L.elem[i]); - } -} \ No newline at end of file From 2b479bc1af392faf6a28cd942e2487a25720de67 Mon Sep 17 00:00:00 2001 From: pkcs2aq9m Date: Fri, 21 Apr 2023 22:37:06 +0800 Subject: [PATCH 14/26] Delete 'student.cpp' --- student.cpp | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 student.cpp diff --git a/student.cpp b/student.cpp deleted file mode 100644 index e4f8e07..0000000 --- a/student.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include -#include "student.h" -using namespace std; - -struct student{ - long int id[10]; ///十位学号 - char name[15]; ///姓名 - long int phonenumber[11]; //手机号 - struct date; //日期 -}; - -struct date{ - int year; - int month; - int day; -}; - -int main() -{ - -} From e25a10b353265244a7778bed717424f86041f23c Mon Sep 17 00:00:00 2001 From: pkcs2aq9m Date: Fri, 21 Apr 2023 22:37:12 +0800 Subject: [PATCH 15/26] Delete 'student.h' --- student.h | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 student.h diff --git a/student.h b/student.h deleted file mode 100644 index 467bd93..0000000 --- a/student.h +++ /dev/null @@ -1,6 +0,0 @@ -/////////////////// -///student.cpp -/////////////////// - - - From 2222568065b09996fcf88ac89b8c5ca5488bdd03 Mon Sep 17 00:00:00 2001 From: pkcs2aq9m Date: Fri, 21 Apr 2023 22:37:17 +0800 Subject: [PATCH 16/26] Delete 'title.cpp' --- title.cpp | 117 ------------------------------------------------------ 1 file changed, 117 deletions(-) delete mode 100644 title.cpp diff --git a/title.cpp b/title.cpp deleted file mode 100644 index 6e04899..0000000 --- a/title.cpp +++ /dev/null @@ -1,117 +0,0 @@ -///程序启动 - -///1 读取 | 2 保存 | 3 打印 | 4 查询 | 5 添加 -///6 修改 | 7 删除 | 8 排序 | 9 图表 | 0 退出 - -///请选择: 0 -///确定要退出吗?(Y/N): no - - - - - - #include - #include - #include "data.h" - - enum { - CMD_QUIT, // 退出 - CMD_READ, // 读取 - CMD_SAVE, // 保存 - CMD_PRINT, // 打印 - CMD_QUERY, // 查询 - CMD_INSERT, // 添加 - CMD_UPDATE, // 修改 - CMD_DELETE, // 删除 - CMD_SORT, // 排序 - CMD_CHART, // 图表 - }; - - - // 函数声明 - void init(void); // 程序启动 - void quit(void); // 程序退出 - void display_menu(void); // 显示命令菜单 - int make_choice(void); // 选择命令 - int confirm(const char* msg); // 确认 - - - // 主函数 - int main(void) - { - init(); // 程序启动 - for(;;) { - display_menu(); // - int c = make_choice(); - switch(c) { - case CMD_READ: - read_data(); - break; - case CMD_SAVE: - save_data(); - break; - case CMD_PRINT: - print_data(); - break; - case CMD_QUERY: - query_data(); - break; - case CMD_INSERT: - add_data(); - break; - case CMD_UPDATE: - update_data(); - break; - case CMD_DELETE: - delete_data(); - break; - case CMD_SORT: - sort_data(); - break; - case CMD_CHART: - make_chart(); - break; - case CMD_QUIT: - if (confirm("确定要退出吗?")) quit(); // 仅在确认后退出 - break; - default: - puts("命令错误,请重新选择"); - break;} - } - quit(); // 程序退出 - return 0; - } - // 函数定义 - void init(void) - { - puts("程序启动"); - } - void quit(void) - { - puts("程序退出"); - exit(EXIT_SUCCESS); - } - void display_menu(void) - { - printf("\n%d 读取 | %d 保存 | %d 打印 | %d 查询 | %d 添加\n%d 修改 | %d 删除 | %d 排序 | %d 图表 | %d 退出\n\n", - CMD_READ,CMD_SAVE,CMD_PRINT,CMD_QUERY,CMD_INSERT,CMD_UPDATE,CMD_DELETE,CMD_SORT,CMD_CHART,CMD_QUIT); - } - int make_choice(void) - { - int c; // 用户输入 - int n = 0; // 正确读入的数据项个数 - while (n == 0) { - printf("请选择:"); - n = scanf("%d", &c); // 尝试读入整数 c - scanf("%*[^\n]"); // 跳过一行中剩余的字符 - } - return c; - } - int confirm(const char* msg) - { - char c = 'n'; // 默认选择是 no - printf("%s(Y/N): ", msg); // 提示输入 yes/no 进行确认 - scanf(" %c%*[^\n]", &c); // 读取第一个字符,忽略剩余字符 - return c == 'y' || c == 'Y'; // 返回确认结果 - } - From e5af14f61763e2769b9e30fea959d3aef303c477 Mon Sep 17 00:00:00 2001 From: pkcs2aq9m Date: Fri, 21 Apr 2023 22:37:48 +0800 Subject: [PATCH 17/26] ADD file via upload --- title.cpp | 124 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 title.cpp diff --git a/title.cpp b/title.cpp new file mode 100644 index 0000000..f501052 --- /dev/null +++ b/title.cpp @@ -0,0 +1,124 @@ + #include + #include + #include + using namespace std; + + + #include "data.h" + #include "sqlist.h" + + enum { + CMD_QUIT, // 退出程序 + CMD_QUERY, // 查书(数量) + CMD_BOOROW, // 借书 + CMD_REPAID, // 还书 + CMD_PRINT, // 打印书籍 + CMD_INSERT, // 添加书籍 + CMD_DELETE, // 删除书籍 + }; + + + // 函数声明 + void init(void); // 程序启动 + void quit(void); // 程序退出 + void display_menu(void); // 显示命令菜单 + + int make_choice(void); // 选择命令 + int confirm(const char* msg); // 确认 + + + + // 主函数 + int main(void) + { + init(); // 程序启动 + + InitList(books); + + for(;;) { + display_menu(); // + int c = make_choice(); + switch(c) { + case CMD_REPAID:// 还书 + {repaid_book(); + DoRepaidBook(); + break;} + case CMD_BOOROW:// 借书 + {boorow_book(); + DoBoorowBook(); + break;} + case CMD_PRINT:// 打印所有书籍 + {print_book(); + DoPrintBook(); + break;} + case CMD_QUERY:// 查找书籍 + {query_book(); + DoFindBook(); + break;} + case CMD_INSERT:// 添加书籍 + {add_book(); + DoAddBook(); + break;} + case CMD_DELETE:// 删除书籍 + {delete_book(); + DoDeleteBook(); + break;} + case CMD_QUIT:// 退出程序 + {if (confirm("确定要退出吗?")) quit(); // 仅在确认后退出 + break;} + default: + puts("命令错误,请重新选择"); + break;} + } + quit(); // 程序退出 + + DestroyList(books); + return 0; + } + + + + + + + void init(void) + { + puts("*******图书管理系统启动*******"); + } + void quit(void) + { + puts("系统退出"); + exit(EXIT_SUCCESS); + } + + + + void display_menu(void) + { + cout << "————————————————————————————————————————————————————————————————"< Date: Fri, 21 Apr 2023 22:38:00 +0800 Subject: [PATCH 18/26] ADD file via upload --- sqlist.h | 177 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 177 insertions(+) create mode 100644 sqlist.h diff --git a/sqlist.h b/sqlist.h new file mode 100644 index 0000000..873a930 --- /dev/null +++ b/sqlist.h @@ -0,0 +1,177 @@ +/////////////////////////////////////// +/// file: sqlist.h +/// Sequential list +/////////////////////////////////////// + +#pragma once + +#include // for std::out_of_range +using std::out_of_range; // 导入名称 +using std::length_error; + +/////////////////////////////////////// +/// 存储结构 + +/// +/// 线性表的顺序存储结构 +/// +template +struct SqList +{ + E elem[MAXSIZE]; + int length; +}; + +/////////////////////////////////////// +/// 基本操作 + +/// +/// 构造空的顺序表 L +/// +template +void InitList(SqList &L) +{ + L.length = 0; // 空表长度为 0 +} + +/// +/// 销毁顺序表 L +/// +template +void DestroyList(SqList &L) +{ + // do nothing +} + +/// +/// 将顺序表 L 置为空表 +/// +template +void ClearList(SqList &L) +{ + L.length = 0; +} + +/// +/// 若 L 为空表,则返回 true,否则返回 false +/// +template +bool ListEmpty(const SqList &L) +{ + return L.length == 0; +} + +/// +/// 返回顺序表 L 中数据元素个数 +/// +template +int ListLength(const SqList &L) +{ + return L.length; +} + +/// +/// 用 e 返回顺序表 L 中第 i 个数据元素,1<=i<=length +/// +template +bool GetElem(const SqList &L, int i, E &e) +{ + // 若 i 值不合法,则返回 false + if (i < 1 || i > L.length) + return false; + + // 取第 i 个元素 + e = L.elem[i - 1]; + + // 返回 true 表示操作成功 + return true; +} + +/// +/// 取顺序表 L 中第 i 个元素 +/// +template +const E &GetElem(const SqList &L, int i) +{ + // 若 i 值不合法,不能取元素 + if (i < 1 || i > L.length) + throw out_of_range("i out of range"); + + // 返回第 i 个元素 + return L.elem[i - 1]; +} + +/// +/// 在顺序表 L 中第 i 个位置之前插入新的数据元素 e +/// +template +void ListInsert(SqList &L, int i, E e) +{ + // 若表满,则不能插入 + if (L.length == MAXSIZE) + throw length_error("L is full"); + // 若 i 值不合法,则不能插入 + if (i < 1 || i > L.length + 1) + throw out_of_range("i out of range"); + + // 插入位置及之后的元素后移 + for (int j = L.length - 1; j >= i - 1; j--) + { + L.elem[j + 1] = L.elem[j]; + } + // 插入元素 + L.elem[i - 1] = e; + // 表长增 1 + L.length++; +} + +/// +/// 在顺序表 L 中删除第 i 个元素,用 e 返回 +/// +template +void ListDelete(SqList &L, int i, E &e) +{ + // 若 i 值不合法,则不能删除 + if (i < 1 || i > L.length) + throw out_of_range("i out of range"); + + // 取出被删除元素 + e = L.elem[i - 1]; + // 被删除元素之后的元素前移 + for (int j = i; j < L.length; j++) + { + L.elem[j - 1] = L.elem[j]; + } + // 表长减 1 + L.length--; +} + +/// +/// 返回顺序表 L 中第一个与 e 满足关系 compare 的数据元素的位序 +/// 若这样的数据元素不存在,则返回 0。 +/// +template +int LocateElem(const SqList &L, const E &e, Cmp compare) +{ + // 逐个取出元素与 e 比较 + for (int i = 0; i < L.length; i++) + { + // 若满足条件,则返回位序 + if (compare(L.elem[i], e)) + return i + 1; + } + + return 0; // 不存在 +} + +/// +/// 遍历顺序表,依次对 L 中的每个数据元素调用函数 visit +/// +template +void ListTraverse(const SqList &L, Func visit) +{ + for (int i = 0; i < L.length; i++) + { + visit(L.elem[i]); + } +} \ No newline at end of file From 8f57d59dbd5b13b08389dd18c7412eac5fb3a398 Mon Sep 17 00:00:00 2001 From: pkcs2aq9m Date: Fri, 21 Apr 2023 22:38:12 +0800 Subject: [PATCH 19/26] ADD file via upload --- data.h | 212 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 212 insertions(+) create mode 100644 data.h diff --git a/data.h b/data.h new file mode 100644 index 0000000..5f19df2 --- /dev/null +++ b/data.h @@ -0,0 +1,212 @@ +#ifndef DATA_H_INCLUDED +#define DATA_H_INCLUDED + +#include +#include "sqlist.h" + + +// 函数声明 + +void print_book(void); // 打印 +void query_book(void); // 查询 +void add_book(void); // 添加 +void delete_book(void); // 删除 +void boorow_book(void); // 借书 +void repaid_book(void); // 还书 + + +void DoAddBook(); // 添加图书 +void DoFindBook(); // 查找图书 +void DoDeleteBook(); // 删除图书 +void DoPrintBook(); // 打印所有图书 +void DoRepaidBook(); // 归还图书 +void DoBoorowBook(); // 借用图书 + + + + +void repaid_book(void) // 还书 + { + printf("还书\n"); + } +void boorow_book(void) // 借书 + { + printf("借书\n"); + } +void query_book(void) // 查询 + { + printf("查书\n"); + } +void print_book(void) // 打印 + { + printf("打印\n"); + } +void add_book(void) // 添加 + { + puts("添加"); + } +void delete_book(void) // 删除 + { + puts("删除"); + } + + + + + +struct Book { + int id; // 编号 + string title; // 标题 + int number; // 数量 + }; + +SqList books; + + // 输入一本书的信息 +void input(Book& b) +{ + cout << "ID : "; + cin >> b.id; + cin.ignore(1024, '\n'); // skip rest chars of the line + cout << "TITLE : "; + getline(cin, b.title); + cout << "Number : "; + while (1){ + cin >> b.number; + if (b.number>0) break; + cout << "Number ERROR" << endl; + cout << "Input again" << endl; + } +} + +// 打印一本书的信息 +void print(const Book& b) +{ + cout << "Book " << endl << endl + <<"**************** id: " << b.id << " ****************" << endl + << "**** title: 《 " << b.title << " 》****" << endl + << "************** Number: " << b.number << " **************" << endl << endl; +} + +// 根据 id 查找图书 +// 若找到,返回元素的位序,找不到时返回 0 +int find(int id) +{ + + for (int i = 1; i <= books.length; i++) + { + if (id == books.elem[i].id){ + return i; + } + } + return 0; // not found +} + + +// 添加图书 +void DoAddBook() +{ + Book book; + input(book); //输入图书 + books.elem[books.length + 1] = book; + books.length++; + print(book); + cout << "*******Added********" << endl; +} + +// 查找图书 +void DoFindBook() +{ + int id; + cout << "Enter book ID: "; + cin >> id; + + Book book; + if (find(id) == 0) + cout << "Not found" << endl; + else + { + book = books.elem[find(id)]; + cout << "Found" << endl; + cout << "************" << endl; + print(book); + } +} + +// 删除图书 +void DoDeleteBook() +{ + int id; + cout << "Which book you wanna delelet?"<> id; + Book e; + if (find(id) == 0) + cout << "Not found" << endl; + else + { + e = books.elem[find(id)]; + print(e); + for (int i = find(id); i < books.length; i++) + { + books.elem[i] = books.elem[i + 1]; + } + --books.length; + cout << "************************" << endl; + cout << "Deleted" << endl; + } +} + +// 打印所有图书 +void DoPrintBook() +{ + int flag = 0; + for (int i = 0; i < books.length; i++) + { + Book e; + e = books.elem[i + 1]; + print(e); + flag++; + } + cout << "Total: "; + cout << flag; + cout << " books" << endl; +} + +// 归还图书 +void DoRepaidBook() +{ + int id; + cout << "Which book you wanna repaid ? " << endl; + cin >> id; + cout << endl; + if (find(id)){ + Book e; + e = books.elem[find(id)]; + ++books.elem[find(id)].number; + }else{ + DoAddBook(); + } +} + +// 借用图书 +void DoBoorowBook() +{ + int id; + cout << "Which book you wanna boorow ? " << endl; + cin >> id; + cout << endl; + if (find(id)){ + if (books.elem[find(id)].number>0) { + Book e; + e = books.elem[find(id)]; + cout<< "*********"<< endl << "OK" << endl << "*********"< Date: Fri, 21 Apr 2023 22:42:53 +0800 Subject: [PATCH 20/26] =?UTF-8?q?=E7=8E=AF=E5=A2=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/tasks.json | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .vscode/tasks.json diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..ccfcfb2 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,28 @@ +{ + "tasks": [ + { + "type": "cppbuild", + "label": "C/C++: g++.exe build active file", + "command": "C:\\mingw64\\bin\\g++.exe", + "args": [ + "-fdiagnostics-color=always", + "-g", + "${file}", + "-o", + "${fileDirname}\\${fileBasenameNoExtension}.exe" + ], + "options": { + "cwd": "${fileDirname}" + }, + "problemMatcher": [ + "$gcc" + ], + "group": { + "kind": "build", + "isDefault": true + }, + "detail": "Task generated by Debugger." + } + ], + "version": "2.0.0" +} \ No newline at end of file From 336c5361b76c4e0ea98826b2aef180bf635462c5 Mon Sep 17 00:00:00 2001 From: yangtengze Date: Fri, 21 Apr 2023 23:00:30 +0800 Subject: [PATCH 21/26] ytz --- book.cpp | 170 ------------------------------------------ data.h | 211 +++++++++++++++++++++++++++++++++++++++++++++------- student.cpp | 21 ------ student.h | 6 -- teammates | 4 - title.cpp | 121 ++++++++++++++++-------------- xiaoming.md | 2 - 7 files changed, 248 insertions(+), 287 deletions(-) delete mode 100644 book.cpp delete mode 100644 student.cpp delete mode 100644 student.h delete mode 100644 teammates delete mode 100644 xiaoming.md diff --git a/book.cpp b/book.cpp deleted file mode 100644 index abb721f..0000000 --- a/book.cpp +++ /dev/null @@ -1,170 +0,0 @@ -#include -using namespace std; - -#include "sqlist.h" // 顺序表 - -// 图书信息 -struct Book { - int id; // 编号 - string title; // 标题 - string author; // 作者 - float price; // 价格 -}; - -// 所有书的列表 -SqList books; - -int get_command(); // 读取命令 -void DoAddBook(); // 添加图书 -void DoFindBook(); // 查找图书 -void DoDeleteBook(); // 删除图书 -void DoPrintBook(); // 打印图书 - -int main() -{ - bool finish = false; - - InitList(books); - - while (!finish) { - switch (get_command()) { - case 1: // Add book - DoAddBook(); - break; - case 2: // Find book - DoFindBook(); - break; - case 3: // Delete book - DoDeleteBook(); - break; - case 4: // Print - DoPrintBook(); - break; - case 0: // Exit - finish = true; - break; - default: // no command - cout << "Error command." << endl; - } - } - - DestroyList(books); - - return 0; -} - -// 读取命令 -int get_command() -{ - int cmd; - cout << "Commands: (1) Add, (2) Find, (3) Delete, (4) Print, (0) Exit\n"; - cout << "Enter your choice (0-4): "; - cin >> cmd; - return cmd; -} - -// 输入一本书的信息 -void read(Book& b) -{ - cout << "ID : "; - cin >> b.id; - cin.ignore(1024, '\n'); // skip rest chars of the line - cout << "TITLE : "; - getline(cin, b.title); - cout << "AUTHOR: "; - getline(cin, b.author); - cout << "PRICE : "; - cin >> b.price; -} - -// 打印一本书的信息 -void print(const Book& b) -{ - cout << "Book { id: " << b.id << "," - << " title:\"" << b.title << "\"," - << " author: \"" << b.author << "\"," - << " price: " << b.price << " }" - << endl; -} - -// 根据 id 查找图书 -// 若找到,返回元素的位序,找不到时返回 0 -int find(int id) -{ - - for (int i = 1; i <= books.length; i++) - { - if (id == books.elem[i].id){ - return i; - } - } - return 0; // not found -} - -// 添加图书 -void DoAddBook() -{ - Book e; - read(e); - books.elem[books.length + 1] = e; - books.length++; - print(e); - cout << "Added" << endl; -} - -// 查找图书 -void DoFindBook() -{ - int id; - cout << "Enter book ID: "; - cin >> id; - Book e; - - if (find(id) == 0) - cout << "Not found" << endl; - else - { - e = books.elem[find(id)]; - print(e); - cout << "Found" << endl; - } -} - -// 删除图书 -void DoDeleteBook() -{ - int id; - cout << "Enter book ID: "; - cin >> id; - Book e; - int c = find(id); - if (find(id) == 0) - cout << "Not found" << endl; - else - { - e = books.elem[c]; - print(e); - for (int i = c; i < books.length; i++) - { - books.elem[i] = books.elem[i + 1]; - } - --books.length; - cout << "Deleted" << endl; - } -} - -// 打印图书 -void DoPrintBook() -{ - int flag = 0; - for (int i = 0; i < books.length; i++) - { - Book e; - e = books.elem[i + 1]; - print(e); - flag++; - } - cout << "Total: "; - cout << flag; - cout << " books" << endl; -} \ No newline at end of file diff --git a/data.h b/data.h index 24e086e..5f19df2 100644 --- a/data.h +++ b/data.h @@ -2,54 +2,211 @@ #define DATA_H_INCLUDED #include +#include "sqlist.h" + + // 函数声明 -void read_data(void); // 读取 -void save_data(void); // 保存 -void print_data(void); // 打印 -void query_data(void); // 查询 -void add_data(void); // 添加 -void update_data(void); // 修改 -void delete_data(void); // 删除 -void sort_data(void); // 排序 -void make_chart(void); // 图表 + +void print_book(void); // 打印 +void query_book(void); // 查询 +void add_book(void); // 添加 +void delete_book(void); // 删除 +void boorow_book(void); // 借书 +void repaid_book(void); // 还书 + + +void DoAddBook(); // 添加图书 +void DoFindBook(); // 查找图书 +void DoDeleteBook(); // 删除图书 +void DoPrintBook(); // 打印所有图书 +void DoRepaidBook(); // 归还图书 +void DoBoorowBook(); // 借用图书 -void read_data(void) + + +void repaid_book(void) // 还书 { - printf("读取\n"); + printf("还书\n"); } -void save_data(void) +void boorow_book(void) // 借书 { - printf("保存\n"); + printf("借书\n"); } -void print_data(void) +void query_book(void) // 查询 { - printf("打印\n"); + printf("查书\n"); } -void query_data(void) +void print_book(void) // 打印 { - printf("查询\n"); - } -void add_data(void) + printf("打印\n"); + } +void add_book(void) // 添加 { puts("添加"); } -void update_data(void) +void delete_book(void) // 删除 { - puts("修改"); + puts("删除"); } -void delete_data(void) + + + + + +struct Book { + int id; // 编号 + string title; // 标题 + int number; // 数量 + }; + +SqList books; + + // 输入一本书的信息 +void input(Book& b) +{ + cout << "ID : "; + cin >> b.id; + cin.ignore(1024, '\n'); // skip rest chars of the line + cout << "TITLE : "; + getline(cin, b.title); + cout << "Number : "; + while (1){ + cin >> b.number; + if (b.number>0) break; + cout << "Number ERROR" << endl; + cout << "Input again" << endl; + } +} + +// 打印一本书的信息 +void print(const Book& b) +{ + cout << "Book " << endl << endl + <<"**************** id: " << b.id << " ****************" << endl + << "**** title: 《 " << b.title << " 》****" << endl + << "************** Number: " << b.number << " **************" << endl << endl; +} + +// 根据 id 查找图书 +// 若找到,返回元素的位序,找不到时返回 0 +int find(int id) +{ + + for (int i = 1; i <= books.length; i++) { - puts("删除"); + if (id == books.elem[i].id){ + return i; + } + } + return 0; // not found +} + + +// 添加图书 +void DoAddBook() +{ + Book book; + input(book); //输入图书 + books.elem[books.length + 1] = book; + books.length++; + print(book); + cout << "*******Added********" << endl; +} + +// 查找图书 +void DoFindBook() +{ + int id; + cout << "Enter book ID: "; + cin >> id; + + Book book; + if (find(id) == 0) + cout << "Not found" << endl; + else + { + book = books.elem[find(id)]; + cout << "Found" << endl; + cout << "************" << endl; + print(book); } -void sort_data(void) +} + +// 删除图书 +void DoDeleteBook() +{ + int id; + cout << "Which book you wanna delelet?"<> id; + Book e; + if (find(id) == 0) + cout << "Not found" << endl; + else { - puts("排序"); + e = books.elem[find(id)]; + print(e); + for (int i = find(id); i < books.length; i++) + { + books.elem[i] = books.elem[i + 1]; + } + --books.length; + cout << "************************" << endl; + cout << "Deleted" << endl; } -void make_chart(void) +} + +// 打印所有图书 +void DoPrintBook() +{ + int flag = 0; + for (int i = 0; i < books.length; i++) { - puts("图表"); + Book e; + e = books.elem[i + 1]; + print(e); + flag++; + } + cout << "Total: "; + cout << flag; + cout << " books" << endl; +} + +// 归还图书 +void DoRepaidBook() +{ + int id; + cout << "Which book you wanna repaid ? " << endl; + cin >> id; + cout << endl; + if (find(id)){ + Book e; + e = books.elem[find(id)]; + ++books.elem[find(id)].number; + }else{ + DoAddBook(); } +} + +// 借用图书 +void DoBoorowBook() +{ + int id; + cout << "Which book you wanna boorow ? " << endl; + cin >> id; + cout << endl; + if (find(id)){ + if (books.elem[find(id)].number>0) { + Book e; + e = books.elem[find(id)]; + cout<< "*********"<< endl << "OK" << endl << "*********"< -#include "student.h" -using namespace std; - -struct student{ - long int id[10]; ///十位学号 - char name[15]; ///姓名 - long int phonenumber[11]; //手机号 - struct date; //日期 -}; - -struct date{ - int year; - int month; - int day; -}; - -int main() -{ - -} diff --git a/student.h b/student.h deleted file mode 100644 index 467bd93..0000000 --- a/student.h +++ /dev/null @@ -1,6 +0,0 @@ -/////////////////// -///student.cpp -/////////////////// - - - diff --git a/teammates b/teammates deleted file mode 100644 index ed9ecba..0000000 --- a/teammates +++ /dev/null @@ -1,4 +0,0 @@ -杨腾泽1 -孙英皓 -刘彩月 -李聪颖 diff --git a/title.cpp b/title.cpp index 6e04899..f501052 100644 --- a/title.cpp +++ b/title.cpp @@ -1,30 +1,20 @@ -///程序启动 - -///1 读取 | 2 保存 | 3 打印 | 4 查询 | 5 添加 -///6 修改 | 7 删除 | 8 排序 | 9 图表 | 0 退出 - -///请选择: 0 -///确定要退出吗?(Y/N): no - - - - - #include #include + #include + using namespace std; + + #include "data.h" + #include "sqlist.h" enum { - CMD_QUIT, // 退出 - CMD_READ, // 读取 - CMD_SAVE, // 保存 - CMD_PRINT, // 打印 - CMD_QUERY, // 查询 - CMD_INSERT, // 添加 - CMD_UPDATE, // 修改 - CMD_DELETE, // 删除 - CMD_SORT, // 排序 - CMD_CHART, // 图表 + CMD_QUIT, // 退出程序 + CMD_QUERY, // 查书(数量) + CMD_BOOROW, // 借书 + CMD_REPAID, // 还书 + CMD_PRINT, // 打印书籍 + CMD_INSERT, // 添加书籍 + CMD_DELETE, // 删除书籍 }; @@ -32,69 +22,83 @@ void init(void); // 程序启动 void quit(void); // 程序退出 void display_menu(void); // 显示命令菜单 + int make_choice(void); // 选择命令 int confirm(const char* msg); // 确认 + // 主函数 int main(void) { init(); // 程序启动 + + InitList(books); + for(;;) { display_menu(); // int c = make_choice(); switch(c) { - case CMD_READ: - read_data(); - break; - case CMD_SAVE: - save_data(); - break; - case CMD_PRINT: - print_data(); - break; - case CMD_QUERY: - query_data(); - break; - case CMD_INSERT: - add_data(); - break; - case CMD_UPDATE: - update_data(); - break; - case CMD_DELETE: - delete_data(); - break; - case CMD_SORT: - sort_data(); - break; - case CMD_CHART: - make_chart(); - break; - case CMD_QUIT: - if (confirm("确定要退出吗?")) quit(); // 仅在确认后退出 - break; + case CMD_REPAID:// 还书 + {repaid_book(); + DoRepaidBook(); + break;} + case CMD_BOOROW:// 借书 + {boorow_book(); + DoBoorowBook(); + break;} + case CMD_PRINT:// 打印所有书籍 + {print_book(); + DoPrintBook(); + break;} + case CMD_QUERY:// 查找书籍 + {query_book(); + DoFindBook(); + break;} + case CMD_INSERT:// 添加书籍 + {add_book(); + DoAddBook(); + break;} + case CMD_DELETE:// 删除书籍 + {delete_book(); + DoDeleteBook(); + break;} + case CMD_QUIT:// 退出程序 + {if (confirm("确定要退出吗?")) quit(); // 仅在确认后退出 + break;} default: puts("命令错误,请重新选择"); break;} } quit(); // 程序退出 + + DestroyList(books); return 0; } - // 函数定义 + + + + + + void init(void) { - puts("程序启动"); + puts("*******图书管理系统启动*******"); } void quit(void) { - puts("程序退出"); + puts("系统退出"); exit(EXIT_SUCCESS); } + + + void display_menu(void) { - printf("\n%d 读取 | %d 保存 | %d 打印 | %d 查询 | %d 添加\n%d 修改 | %d 删除 | %d 排序 | %d 图表 | %d 退出\n\n", - CMD_READ,CMD_SAVE,CMD_PRINT,CMD_QUERY,CMD_INSERT,CMD_UPDATE,CMD_DELETE,CMD_SORT,CMD_CHART,CMD_QUIT); + cout << "————————————————————————————————————————————————————————————————"< Date: Fri, 21 Apr 2023 23:08:21 +0800 Subject: [PATCH 22/26] change 1 --- data.h | 6 ++++++ title.cpp | 6 ------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/data.h b/data.h index 5f19df2..0955567 100644 --- a/data.h +++ b/data.h @@ -28,26 +28,32 @@ void DoBoorowBook(); // 借用图书 void repaid_book(void) // 还书 { printf("还书\n"); + DoRepaidBook(); } void boorow_book(void) // 借书 { printf("借书\n"); + DoBoorowBook(); } void query_book(void) // 查询 { printf("查书\n"); + DoFindBook(); } void print_book(void) // 打印 { printf("打印\n"); + DoPrintBook(); } void add_book(void) // 添加 { puts("添加"); + DoAddBook(); } void delete_book(void) // 删除 { puts("删除"); + DoDeleteBook(); } diff --git a/title.cpp b/title.cpp index f501052..0e3f6d7 100644 --- a/title.cpp +++ b/title.cpp @@ -41,27 +41,21 @@ switch(c) { case CMD_REPAID:// 还书 {repaid_book(); - DoRepaidBook(); break;} case CMD_BOOROW:// 借书 {boorow_book(); - DoBoorowBook(); break;} case CMD_PRINT:// 打印所有书籍 {print_book(); - DoPrintBook(); break;} case CMD_QUERY:// 查找书籍 {query_book(); - DoFindBook(); break;} case CMD_INSERT:// 添加书籍 {add_book(); - DoAddBook(); break;} case CMD_DELETE:// 删除书籍 {delete_book(); - DoDeleteBook(); break;} case CMD_QUIT:// 退出程序 {if (confirm("确定要退出吗?")) quit(); // 仅在确认后退出 From 70d3bb5147adc6c0ebb9d0865edbf56a490397fb Mon Sep 17 00:00:00 2001 From: yangtengze Date: Sat, 22 Apr 2023 14:31:35 +0800 Subject: [PATCH 23/26] change 2 --- .vscode/settings.json | 7 +++ .vscode/tasks.json | 28 +++++++++++ data.h | 112 ++++++++++++++++++++++-------------------- title.cpp | 28 +++++++---- 4 files changed, 111 insertions(+), 64 deletions(-) create mode 100644 .vscode/settings.json create mode 100644 .vscode/tasks.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..36f10cd --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "files.associations": { + "iostream": "cpp", + "ostream": "cpp", + "stdexcept": "cpp" + } +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..ccfcfb2 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,28 @@ +{ + "tasks": [ + { + "type": "cppbuild", + "label": "C/C++: g++.exe build active file", + "command": "C:\\mingw64\\bin\\g++.exe", + "args": [ + "-fdiagnostics-color=always", + "-g", + "${file}", + "-o", + "${fileDirname}\\${fileBasenameNoExtension}.exe" + ], + "options": { + "cwd": "${fileDirname}" + }, + "problemMatcher": [ + "$gcc" + ], + "group": { + "kind": "build", + "isDefault": true + }, + "detail": "Task generated by Debugger." + } + ], + "version": "2.0.0" +} \ No newline at end of file diff --git a/data.h b/data.h index 0955567..61b738f 100644 --- a/data.h +++ b/data.h @@ -5,15 +5,19 @@ #include "sqlist.h" -// 函数声明 +struct Book { + int id; // 编号 + string title; // 标题 + int number; // 数量 + }; -void print_book(void); // 打印 -void query_book(void); // 查询 -void add_book(void); // 添加 -void delete_book(void); // 删除 -void boorow_book(void); // 借书 -void repaid_book(void); // 还书 +SqList books; +// 函数声明 +bool bookempty(); // 书籍库判空 +void input(Book& b); // 输入一本书的信息 +void print(const Book& b);// 打印一本书的信息 +int find(int id); // 根据 id 查找图书 || 若找到,返回元素的位序,找不到时返回 0 void DoAddBook(); // 添加图书 void DoFindBook(); // 查找图书 @@ -21,54 +25,11 @@ void DoDeleteBook(); // 删除图书 void DoPrintBook(); // 打印所有图书 void DoRepaidBook(); // 归还图书 void DoBoorowBook(); // 借用图书 +void DoReviseBook(); // 修改图书 +void DoSortBook(); // 排序图书 - - -void repaid_book(void) // 还书 - { - printf("还书\n"); - DoRepaidBook(); - } -void boorow_book(void) // 借书 - { - printf("借书\n"); - DoBoorowBook(); - } -void query_book(void) // 查询 - { - printf("查书\n"); - DoFindBook(); - } -void print_book(void) // 打印 - { - printf("打印\n"); - DoPrintBook(); - } -void add_book(void) // 添加 - { - puts("添加"); - DoAddBook(); - } -void delete_book(void) // 删除 - { - puts("删除"); - DoDeleteBook(); - } - - - - - -struct Book { - int id; // 编号 - string title; // 标题 - int number; // 数量 - }; - -SqList books; - - // 输入一本书的信息 +// 输入一本书的信息 void input(Book& b) { cout << "ID : "; @@ -108,10 +69,22 @@ int find(int id) return 0; // not found } +// 书籍库判空 +bool bookempty() +{ + int a=0; + for (int i=1;i<=books.length;i++) + { + if (find(i)==0) a++; + } + if (a==books.length) return true; + else return false; +} // 添加图书 void DoAddBook() { + cout << endl << "Add Book"<< endl<> id; @@ -142,6 +116,7 @@ void DoFindBook() // 删除图书 void DoDeleteBook() { + cout << endl << "Delete Book" << endl << endl; int id; cout << "Which book you wanna delelet?"<> id; @@ -198,6 +175,7 @@ void DoRepaidBook() // 借用图书 void DoBoorowBook() { + cout << endl << "Boorow Book" << endl <> id; @@ -210,9 +188,35 @@ void DoBoorowBook() --books.elem[find(id)].number; }else cout << "***************************"<< endl << "Book empty" << endl << "***************************" << endl; - }else throw "NOT FOUND THIS BOOK"; + }else cout<< "NOT FOUND THIS BOOK"<> id; + if ( find(id)!=0 ) { + printf ( "Original book number : %d\n", books.elem[id].number ); + printf ( "Revised number :" ); + int xiugai; + scanf ( "%d", &xiugai ); + books.elem[id].number+=xiugai; + cout << "**********************" << endl; + printf ( "Revise success \n" ); + } + else printf ( "No such book\n"); +} + +// 排序图书 +void DoSortBook() +{ + cout << endl << "Sort Books" << endl << endl; + int a=0; + if (bookempty()) cout << "Book data empty"<< endl; +} #endif // DATA_H_INCLUDED \ No newline at end of file diff --git a/title.cpp b/title.cpp index 0e3f6d7..007ba69 100644 --- a/title.cpp +++ b/title.cpp @@ -10,11 +10,13 @@ enum { CMD_QUIT, // 退出程序 CMD_QUERY, // 查书(数量) - CMD_BOOROW, // 借书 - CMD_REPAID, // 还书 + CMD_BOOROW, // 借用书籍 + CMD_REPAID, // 归还书籍 CMD_PRINT, // 打印书籍 CMD_INSERT, // 添加书籍 CMD_DELETE, // 删除书籍 + CMD_UPDATE, // 修改书籍 + CMD_SORT, // 排序书籍 }; @@ -40,22 +42,28 @@ int c = make_choice(); switch(c) { case CMD_REPAID:// 还书 - {repaid_book(); + {DoRepaidBook(); break;} case CMD_BOOROW:// 借书 - {boorow_book(); + {DoBoorowBook(); break;} case CMD_PRINT:// 打印所有书籍 - {print_book(); + {DoPrintBook(); break;} case CMD_QUERY:// 查找书籍 - {query_book(); + {DoFindBook(); break;} case CMD_INSERT:// 添加书籍 - {add_book(); + {DoAddBook(); break;} case CMD_DELETE:// 删除书籍 - {delete_book(); + {DoDeleteBook(); + break;} + case CMD_UPDATE:// 修改书籍 + {DoReviseBook(); + break;} + case CMD_SORT: // 排序书籍 + {DoSortBook(); break;} case CMD_QUIT:// 退出程序 {if (confirm("确定要退出吗?")) quit(); // 仅在确认后退出 @@ -90,8 +98,8 @@ void display_menu(void) { cout << "————————————————————————————————————————————————————————————————"< Date: Sat, 22 Apr 2023 14:39:47 +0800 Subject: [PATCH 24/26] 1 --- .vscode/tasks.json | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .vscode/tasks.json diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..5f7109c --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,28 @@ +{ + "tasks": [ + { + "type": "cppbuild", + "label": "C/C++: g++.exe 生成活动文件", + "command": "D:\\mingw64\\bin\\g++.exe", + "args": [ + "-fdiagnostics-color=always", + "-g", + "${file}", + "-o", + "${fileDirname}\\${fileBasenameNoExtension}.exe" + ], + "options": { + "cwd": "${fileDirname}" + }, + "problemMatcher": [ + "$gcc" + ], + "group": { + "kind": "build", + "isDefault": true + }, + "detail": "调试器生成的任务。" + } + ], + "version": "2.0.0" +} \ No newline at end of file From 1788b2c28e97cea2fd55232f725b14182cc40bc5 Mon Sep 17 00:00:00 2001 From: yangtengze Date: Sat, 22 Apr 2023 14:51:43 +0800 Subject: [PATCH 25/26] a --- .vscode/tasks.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/.vscode/tasks.json b/.vscode/tasks.json index acdd131..ccfcfb2 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -2,8 +2,6 @@ "tasks": [ { "type": "cppbuild", - "label": "C/C++: g++.exe 生成活动文件", - "command": "D:\\mingw64\\bin\\g++.exe", "label": "C/C++: g++.exe build active file", "command": "C:\\mingw64\\bin\\g++.exe", "args": [ @@ -23,7 +21,6 @@ "kind": "build", "isDefault": true }, - "detail": "调试器生成的任务。" "detail": "Task generated by Debugger." } ], From 8c6dac2eb073be4e6691abdebfe75e8d8513c33d Mon Sep 17 00:00:00 2001 From: yangtengze Date: Sat, 22 Apr 2023 14:53:17 +0800 Subject: [PATCH 26/26] a --- .vscode/tasks.json | 28 ---------------------------- 1 file changed, 28 deletions(-) delete mode 100644 .vscode/tasks.json diff --git a/.vscode/tasks.json b/.vscode/tasks.json deleted file mode 100644 index ccfcfb2..0000000 --- a/.vscode/tasks.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "tasks": [ - { - "type": "cppbuild", - "label": "C/C++: g++.exe build active file", - "command": "C:\\mingw64\\bin\\g++.exe", - "args": [ - "-fdiagnostics-color=always", - "-g", - "${file}", - "-o", - "${fileDirname}\\${fileBasenameNoExtension}.exe" - ], - "options": { - "cwd": "${fileDirname}" - }, - "problemMatcher": [ - "$gcc" - ], - "group": { - "kind": "build", - "isDefault": true - }, - "detail": "Task generated by Debugger." - } - ], - "version": "2.0.0" -} \ No newline at end of file