Discarded cards: , , , , ,
Remaining card:
Discarded cards: , , , , , , , , , , , , , , , , ,
Remaining card:
Discarded cards: , , , , , , , ,
Remaining card:
Discarded cards: , , , ,
Remaining card:
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <queue>
using namespace std;
#define MAX_N 15
int main103()
{
freopen("data5_3_h.in", "r", stdin);
freopen("data5_3_h.out", "w", stdout);
int num,first_ele;
while (cin>>num&&num!=)
{
queue<int> card; //使用队列进行模拟
bool flag = false;
for (int i = ; i <= num; i++)
card.push(i);
cout << "Discarded cards: ";
while (card.size()!=)
{
if (!flag)
{
cout << card.front();
if (card.size() != )
cout << ", ";
}
else
card.push(card.front());
card.pop();
flag = !flag;
}
cout << "\nRemaining card:" << card.front() << endl;
}
freopen("CON", "r", stdin);
freopen("CON", "w", stdout);
return ;
}