您的位置: 首页 > IT文章 > list-begin list-begin 分类: IT文章 • 2025-01-15 16:22:07 //////////////////////////////////////// // 2018/04/25 21:12:41 // list-begin // return an iterator to the beginning #include <iostream> #include <list> #include <algorithm> #include <iterator> #include <numeric> using namespace std; int main(){ list<int> l(5); iota(l.begin(), l.end(), 1); list<int>::iterator it = l.begin(); while (it != l.end()){ cout << *(it++) << " "; } cout << endl; // third element of the list it = l.begin(); it++; it++; cout << *it << endl; return 0; } /* OUTPUT: 1 2 3 4 5 3 */