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;
}


相关文章:

  • 2022-12-23
  • 2021-09-09
  • 2021-07-30
猜你喜欢
  • 2021-05-25
  • 2021-12-29
  • 2021-12-15
  • 2021-08-07
  • 2022-01-23
  • 2021-08-29
相关资源
相似解决方案