Throwing cards away I UVA - 10935

问题类型:STL-queue应用。

03pie’s solution for [UVA-10935]
问题链接

#include 
#include

using namespace std;

const int maxn=50;

int main(){
    //freopen("F://inp.txt","r",stdin);
    int n;
    while(cin>>n&&n){
        queue<int> cards;
        for(int i=0;i1);
        }
        int len=cards.size();
        cout<<"Discarded cards:";
        if(len>1){
                while(--len){
                cout<<" "<//输出队首元素 
                if(len>1)   cout<<",";
                cards.pop();//队首出队 
                cards.push(cards.front());//将新队首元素放在队尾 
                cards.pop();//队首出队 
            }
        }
//      else    cout<
        cout<<"\nRemaining card: "<return 0;
}

你可能感兴趣的:(Throwing cards away I UVA - 10935)