uva10935卡牌游戏
没什么好说的,主要就是卡格式坑爹
#include
#include
#include
using namespace std;
int main()
{
int n;
while(cin>>n&&n)
{
vector<int> card;
vector<int> hapi;
card.clear();
hapi.clear();
for(int i=n;i>=1;i--)
{
card.push_back(i);
}
while(card.size()!=1)
{
int temp=card.back();
card.pop_back();
hapi.push_back(temp);
temp=card.back();
card.insert(card.begin(),temp);
card.pop_back();
}
cout<<"Discarded cards:";
for(int i=0;i<hapi.size();i++)
{
if(i==0&&hapi.size()>=2)
cout<<' '<<hapi[i]<<", ";
else if(i==0&&hapi.size()==1)
cout<<" "<<hapi[i];
else if(i==hapi.size()-1)
cout<<hapi[i];
else
cout<<hapi[i]<<", ";
}
cout<<endl;
cout<<"Remaining card: "<<card.back()<<endl;
}
}