添加了小人出列的列表

This commit is contained in:
A.C.Sukazyo Eyre 2022-10-27 00:00:09 +08:00
parent 4836734b78
commit 04fc6c3604
Signed by: Eyre_S
GPG Key ID: C17CE40291207874

View File

@ -1,5 +1,6 @@
#include <iostream> #include <iostream>
#include <cstring> #include <cstring>
#include <sstream>
#include <limits.h> #include <limits.h>
struct node { struct node {
@ -64,6 +65,8 @@ int main () {
std::cout << "招募了小人 #" << 1 << " , 它前面是 #" << (*(*curr).prev).id << " , 它后面是 #" << (*(*curr).next).id << std::endl; std::cout << "招募了小人 #" << 1 << " , 它前面是 #" << (*(*curr).prev).id << " , 它后面是 #" << (*(*curr).next).id << std::endl;
} }
std::stringstream out_roll;
int counting = 0; int counting = 0;
node* next_one = (*first).prev; node* next_one = (*first).prev;
while (count > 1) { while (count > 1) {
@ -72,6 +75,7 @@ int main () {
counting++; counting++;
std::cout << "小人 #" << (*current).id << " 数到了" << counting; std::cout << "小人 #" << (*current).id << " 数到了" << counting;
if (counting == 3) { if (counting == 3) {
out_roll << "#" << (*current).id << " ";
remove_one(current); remove_one(current);
counting = 0; counting = 0;
count--; count--;
@ -84,6 +88,7 @@ int main () {
std::cout << "=====" << std::endl std::cout << "=====" << std::endl
<< "最终剩下了小人 #" << (*next_one).id << " !" << std::endl; << "最终剩下了小人 #" << (*next_one).id << " !" << std::endl;
std::cout << "小人的出列顺序是: " << out_roll.str() << "." << std::endl;
return 0; return 0;