Throwing cards away (UVA原题的链接单击这里哦???)
Generally,? the following is a simple quize about queue container.?
#include<queue>
#include <iostream>
using namespace std;
int main() {
int t;
while (cin >> t && t != 0) {
queue<int> card;
for (int i = 1; i <= t; ++i) card.push(i);
cout << "Discarded cards:";//这里不要有空格,不然会有presentation error
for (int j = t; j >= 2; --j) {
if (j != t) cout << ",";//这里不要有空格,不然会有presentation error
cout <<' '<<card.front();
card.pop();
card.push(card.front());
card.pop();
}
cout << "\nRemaining card: " << card.front() << endl;
}
return 0;
}