还以为这样处理多组用例会出错,没想到竟然没问题~~~那还挺简单的 #include<bits/stdc++.h> using namespace std; int main() { vector vs; string s; while(cin>>s) vs.push_back(s); for(vector::reverse_iterator it=vs.rbegin();it!=vs.rend();it++) { cout<<*it<<" "; } }