From 8d3fdd54ddbf42224d9b1de9246daea0a7a19da5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=A1=E5=9D=82=E6=98=B4?= Date: Thu, 24 Oct 2024 00:47:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E7=AC=AC=E5=9B=9B?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- homework3/CMakeLists.txt | 2 ++ homework3/LinkQueue.cpp | 6 ++++++ homework3/LinkQueue.h | 7 +++++++ homework3/test3.cpp | 18 ++++++++++++++++++ homework3/test4.cpp | 9 +++++++++ 5 files changed, 42 insertions(+) create mode 100644 homework3/LinkQueue.cpp create mode 100644 homework3/LinkQueue.h create mode 100644 homework3/test4.cpp diff --git a/homework3/CMakeLists.txt b/homework3/CMakeLists.txt index 884f031..2d482e7 100644 --- a/homework3/CMakeLists.txt +++ b/homework3/CMakeLists.txt @@ -13,3 +13,5 @@ add_executable(test2 test2.cpp add_executable(test3 test3.cpp SeqQueue.cpp SeqQueue.h) +add_executable(test4 LinkQueue.cpp LinkQueue.h + test4.cpp) diff --git a/homework3/LinkQueue.cpp b/homework3/LinkQueue.cpp new file mode 100644 index 0000000..32f8da1 --- /dev/null +++ b/homework3/LinkQueue.cpp @@ -0,0 +1,6 @@ +//LinkQueue.cpp + +#include "LinkQueue.h" +#include + +using namespace std; diff --git a/homework3/LinkQueue.h b/homework3/LinkQueue.h new file mode 100644 index 0000000..02d27b1 --- /dev/null +++ b/homework3/LinkQueue.h @@ -0,0 +1,7 @@ +//LinkQueue.h + +#ifndef LINKQUEUE_H +#define LINKQUEUE_H + + +#endif //LINKQUEUE_H diff --git a/homework3/test3.cpp b/homework3/test3.cpp index 501b2f2..c7f99de 100644 --- a/homework3/test3.cpp +++ b/homework3/test3.cpp @@ -5,5 +5,23 @@ using namespace std; int main() { + SeqQueue q; + initSeqQueue(q); + if (isEmpty(q)) { + //判断队空 + cout << "此队伍为空" << endl; + } + + for (int i = 1; i <= MAX_SIZE; i++) { + enQueue(q, i); //入队 + } + if (isFull(q)) { + //判断队满 + cout << "此队伍已满" << endl; + } + while (!isEmpty(q)) { + cout << deQueue(q) << " "; //出队 + } + cout << endl; return 0; } diff --git a/homework3/test4.cpp b/homework3/test4.cpp new file mode 100644 index 0000000..3c0dc82 --- /dev/null +++ b/homework3/test4.cpp @@ -0,0 +1,9 @@ +//test4.cpp +#include"LinkQueue.h" +#include + +using namespace std; + +int main() { + return 0; +}