声明一个双向队列,先入后出即可满足要求 class Solution { public: string ReverseSentence(string str) { string tmp=""; deque<string> de; for(auto strnum:str) { if(strnum==' ') { de.push_back(tmp); tmp=""; } else { tmp=tmp+strnum; } } de.push_back(tmp); string result=de.back(); de.pop_back(); while(!de.empty()) { re...