POJ 2013 Symmetric Order

       2013年 新年快乐!

       输入很多字符串,按照一定顺序将其输出。

 

#include <iostream>
#include <stack>
#include <queue>
using namespace std;
stack<string> s;
queue<string> q;
int main()
{
    int prob,n,i,j;
    bool f;
    char str[40];
    prob=1;
    while (1)
    {
        while (!s.empty())
            s.pop();
        while (!q.empty())
            q.pop();
        cin>>n;
        if (n == 0)
            break;
        f=true;
        for (i=0; i<n; i++)
        {
            cin>>str;
            if (f == true)
                q.push(str);
            else
                s.push(str);
            f=!f;
        }
        cout<<"SET "<<prob<<endl;
        prob++;
        f=true;
        while (!q.empty())
        {
            cout<<q.front()<<endl;
            q.pop();
        }
        while (!s.empty())
        {
            cout<<s.top()<<endl;
            s.pop();
        }
    }
}


你可能感兴趣的:(POJ 2013 Symmetric Order)