ex9.9 发表于 2016-01-02 | 分类于 Code , Cpp | 版权声明:自由转载-非商用-非衍生-保持署名 | Creative Commons BY-NC-ND 4.0 Exercise 9.9编写一个循环将 list 以逆序输出 123456789101112131415161718192021222324252627#include <vector>#include <list>#include <deque>#include <iostream>#include <string>using namespace std;int main(){ string s[] = { "hi", "hey", "hello" }; list<string> slist(s, s + 3); list<string>::iterator iter = --slist.end(); int sz = sizeof(s) / sizeof(s[0]); int cnt = 0; while (cnt < sz) { cout << (*iter) << endl; if (++cnt < sz) { --iter; } } return 0;}// prints:// hello// hey// hi