From fad43a024687cdb5b659437d9d6a4142beeaacc0 Mon Sep 17 00:00:00 2001 From: iridiumR Date: Thu, 18 Nov 2021 20:54:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ex8/ex8.cpp | 8 ++++++-- ex8/list.hpp | 2 +- ex8/queue.hpp | 6 ++++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ex8/ex8.cpp b/ex8/ex8.cpp index 2715b10..e72d671 100644 --- a/ex8/ex8.cpp +++ b/ex8/ex8.cpp @@ -38,7 +38,7 @@ public: { if (temp[i].back() < come.front()) { - printf("将车厢%d引入缓冲轨道%d \n", come.front(), i + 1); + printf("%d号车厢推入#%d缓冲轨 \n", come.front(), i + 1); temp[i].enqueue(come.dequeue()); } else @@ -60,8 +60,12 @@ public: { if(temp[j].front()==i) { - printf("将缓冲轨道%d中的车厢%d引入出发序列\n", j+1,temp[j].front()); + printf("%d号车厢经#%d缓冲轨推入出发区,出发队列为 ", j+1,temp[j].front()); out.enqueue(temp[j].dequeue()); + for (int i = 0; i < out.size(); i++) + printf("%d ", out[i]); + printf("\n"); + i++; } } diff --git a/ex8/list.hpp b/ex8/list.hpp index ec63314..a697e81 100644 --- a/ex8/list.hpp +++ b/ex8/list.hpp @@ -46,7 +46,7 @@ public: Node find(int i); T remove(T i); - int operator[](int i) + T operator[](int i) { Node p = first(); while (0 < i--) diff --git a/ex8/queue.hpp b/ex8/queue.hpp index c3c6e2c..c2b6984 100644 --- a/ex8/queue.hpp +++ b/ex8/queue.hpp @@ -9,6 +9,12 @@ class Queue private: List q; public: + + T operator[](int i) + { + return q[i]; + } + int size() { return q.size();