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