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();