用栈的先进后出特性
#include<iostream> #include<stack> using namespace std; int main() { stack<string> a; string s; while(cin>>s) a.push(s); while(!a.empty()){ cout<<a.top()<<" "; a.pop(); } return 0; }