【链接】 我是链接,点我呀:)
【题意】
【题解】
用STL的queue写【代码】
#include <bits/stdc++.h>
using namespace std;
queue <int> dl;
vector <int> v;
int n;
int main()
{
//freopen("F:\rush.txt", "r", stdin);
while (~scanf("%d", &n) && n)
{
v.clear();
while (!dl.empty()) dl.pop();
for (int i = 1; i <= n; i++) dl.push(i);
for (int i = 1; i <= n - 1; i++)
{
v.push_back(dl.front());
dl.pop();
dl.push(dl.front());
dl.pop();
}
printf("Discarded cards:");
for (int i = 0; i < n - 1; i++)
{
printf(" %d%c", v[i], i == n - 2 ? '
' : ',');
}
if (n == 1) puts("");
printf("Remaining card: %d
", dl.front());
}
return 0;
}