From 04fc6c36046a2eed6ff18fc6922ff342438c6cad Mon Sep 17 00:00:00 2001 From: Eyre_S Date: Thu, 27 Oct 2022 00:00:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=86=E5=B0=8F=E4=BA=BA?= =?UTF-8?q?=E5=87=BA=E5=88=97=E7=9A=84=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- quiz4/quiz4.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/quiz4/quiz4.cpp b/quiz4/quiz4.cpp index bb452ad..79f290d 100644 --- a/quiz4/quiz4.cpp +++ b/quiz4/quiz4.cpp @@ -1,5 +1,6 @@ #include #include +#include #include struct node { @@ -64,6 +65,8 @@ int main () { std::cout << "招募了小人 #" << 1 << " , 它前面是 #" << (*(*curr).prev).id << " , 它后面是 #" << (*(*curr).next).id << std::endl; } + std::stringstream out_roll; + int counting = 0; node* next_one = (*first).prev; while (count > 1) { @@ -72,6 +75,7 @@ int main () { counting++; std::cout << "小人 #" << (*current).id << " 数到了" << counting; if (counting == 3) { + out_roll << "#" << (*current).id << " "; remove_one(current); counting = 0; count--; @@ -84,6 +88,7 @@ int main () { std::cout << "=====" << std::endl << "最终剩下了小人 #" << (*next_one).id << " !" << std::endl; + std::cout << "小人的出列顺序是: " << out_roll.str() << "." << std::endl; return 0;