#include <iostream> #include <map> #include <unordered_set> #include <string> #include <algorithm> #include <vector> using namespace std; // 默认输入合法 int main(){ std::ios::sync_with_stdio(false); std::cin.tie(nullptr); std::cout.tie(nullptr); std::setvbuf(stdout, nullptr, _IOFBF, BUFSIZ); vector<string> sentence; string str; //默认输入合法 while (cin>>str) { sentence.push_back(move(str)); } const auto end = sentence.crend(); auto it = sentence.crbegin(); while (it != end) { cout<<*it<<" "; it++; } return 0; }
反向迭代器