diff --git "a/955028\345\220\263\345\256\207\347\222\2770504.cpp" "b/955028\345\220\263\345\256\207\347\222\2770504.cpp" new file mode 100644 index 0000000..bd9040b --- /dev/null +++ "b/955028\345\220\263\345\256\207\347\222\2770504.cpp" @@ -0,0 +1,34 @@ +#include +#include +using namespace std; + +int main() { + int n; + cin >> n; + + while (!(n == 0)) { + queue cards; + + for (int i = 1; i <= n; i++) { + cards.push(i); + } + + cout << "Discarded cards: "; + + while (cards.size() > 1) { + cout << cards.front(); + if (cards.size() == 2) { + cout << ""; + } else { + cout << ", "; + } + + cards.pop(); + cards.push(cards.front()); + cards.pop(); + } + + cout << endl << "Remaining card: " << cards.front() << endl; + cin >> n; + } +} \ No newline at end of file