赵乐ACM

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

1. 简单题,故意用了栈,另外从这个题上可以体会到OJ判题模式



#include <iostream>
#include <cstdio>
#include <stack>
using namespace std;

int main()
{
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    stack<string> st;
    int i, j, n;
    string str;
    for (i = 1; ; i++)
    {
        cin >> n;
        if (n == 0)
            break;
        cout << "SET " << i << endl;
        for (j = 1; j <= n; j++)
        {
            cin >> str;
            if (j % 2 == 1)
                cout << str << endl;
            else st.push(str);
        }
        while (!st.empty())
        {
            cout << st.top() << endl;
            st.pop();
        }
    }
    return 0;
}


posted on 2012-03-29 14:34  赵乐ACM  阅读(182)  评论(0编辑  收藏  举报